Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isort #290

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wpiformat/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies = [
"clang-format==18.1.1",
"clang-tidy==18.1.1",
"gersemi==0.11.0",
"isort==5.11.2",
"regex==2024.9.11"
]
classifiers = [
Expand Down
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/clangformat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""This task runs clang-format on the file."""

from subprocess import Popen, PIPE
import sys
from subprocess import PIPE, Popen

import clang_format

Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""This class is for handling wpiformat config files."""

import os
import regex
import sys

import regex


class Config:
def __init__(self, directory, file_name):
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/includeguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""

import os
from enum import Enum

import regex

from enum import Enum
from wpiformat.task import PipelineTask


Expand Down
1 change: 1 addition & 0 deletions wpiformat/wpiformat/includeorder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This task sorts C/C++ includes."""

import os

import regex

from wpiformat.task import PipelineTask
Expand Down
5 changes: 3 additions & 2 deletions wpiformat/wpiformat/licenseupdate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""This task updates the license header at the top of the file."""

from datetime import date
import os
import regex
import subprocess
from datetime import date

import regex

from wpiformat.config import Config
from wpiformat.task import PipelineTask
Expand Down
7 changes: 7 additions & 0 deletions wpiformat/wpiformat/pyformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ def run_batch(config_file, names):
print("Error: black not found in PATH. Is it installed?", file=sys.stderr)
return False

try:
args = [sys.executable, "-m", "isort", "--profile", "black", "-q"]
subprocess.run(args + names)
except FileNotFoundError:
print("Error: isort not found in PATH. Is it installed?", file=sys.stderr)
return False

return True
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Task base classes for wpiformat."""

from abc import ABCMeta, abstractmethod
import subprocess
from abc import ABCMeta, abstractmethod


class Task(metaclass=ABCMeta):
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_bracecomment.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.bracecomment import BraceComment

from .test_tasktest import *


def test_bracecomment():
test = TaskTest(BraceComment())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_cidentlist.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.cidentlist import CIdentList

from .test_tasktest import *


def test_cidentlist():
test = TaskTest(CIdentList())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_eofnewline.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.eofnewline import EofNewline

from .test_tasktest import *


def test_eofnewline():
test = TaskTest(EofNewline())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_gtestname.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.gtestname import GTestName

from .test_tasktest import *


def test_gtestname():
test = TaskTest(GTestName())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_includeguard.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os

from .test_tasktest import *
from wpiformat.includeguard import IncludeGuard
from wpiformat.task import Task

from .test_tasktest import *


def test_includeguard():
test = TaskTest(IncludeGuard())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_includeorder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.includeorder import IncludeOrder

from .test_tasktest import *


def test_includeorder():
test = TaskTest(IncludeOrder())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_javaclass.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.javaclass import JavaClass

from .test_tasktest import *


def test_javaclass():
test = TaskTest(JavaClass())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_jni.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.jni import Jni

from .test_tasktest import *


def test_jni():
test = TaskTest(Jni())
Expand Down
7 changes: 4 additions & 3 deletions wpiformat/wpiformat/test/test_licenseupdate.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from datetime import date
import os
from pathlib import Path
import subprocess
import tempfile
from datetime import date
from pathlib import Path

from .test_tasktest import *
from wpiformat.config import Config
from wpiformat.licenseupdate import LicenseUpdate

from .test_tasktest import *


class OpenTemporaryDirectory:
def __init__(self):
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_stdlib.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.stdlib import Stdlib

from .test_tasktest import *


def test_stdlib():
test = TaskTest(Stdlib())
Expand Down
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/test/test_tasktest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""This class is for writing unit tests for tasks."""

from enum import Enum
import io
import os
import sys
from enum import Enum

from wpiformat.config import Config

Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_usingdeclaration.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.usingdeclaration import UsingDeclaration

from .test_tasktest import *


def test_usingdeclaration():
test = TaskTest(UsingDeclaration())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_usingnamespacestd.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.usingnamespacestd import UsingNamespaceStd

from .test_tasktest import *


def test_usingnamespacestd():
test = TaskTest(UsingNamespaceStd())
Expand Down
3 changes: 2 additions & 1 deletion wpiformat/wpiformat/test/test_whitespace.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from .test_tasktest import *
from wpiformat.whitespace import Whitespace

from .test_tasktest import *


def test_whitespace():
test = TaskTest(Whitespace())
Expand Down
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import date
import subprocess
from datetime import date


def get_version():
Expand Down