diff --git a/wpiformat/pyproject.toml b/wpiformat/pyproject.toml index 32f964d..c62ac1a 100644 --- a/wpiformat/pyproject.toml +++ b/wpiformat/pyproject.toml @@ -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 = [ diff --git a/wpiformat/wpiformat/clangformat.py b/wpiformat/wpiformat/clangformat.py index 985bb0d..a0d9e5c 100644 --- a/wpiformat/wpiformat/clangformat.py +++ b/wpiformat/wpiformat/clangformat.py @@ -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 diff --git a/wpiformat/wpiformat/config.py b/wpiformat/wpiformat/config.py index d84e252..1564391 100644 --- a/wpiformat/wpiformat/config.py +++ b/wpiformat/wpiformat/config.py @@ -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): diff --git a/wpiformat/wpiformat/includeguard.py b/wpiformat/wpiformat/includeguard.py index 0851ad3..eca397a 100644 --- a/wpiformat/wpiformat/includeguard.py +++ b/wpiformat/wpiformat/includeguard.py @@ -3,9 +3,10 @@ """ import os +from enum import Enum + import regex -from enum import Enum from wpiformat.task import PipelineTask diff --git a/wpiformat/wpiformat/includeorder.py b/wpiformat/wpiformat/includeorder.py index 4f2af6b..7c0fb48 100644 --- a/wpiformat/wpiformat/includeorder.py +++ b/wpiformat/wpiformat/includeorder.py @@ -1,6 +1,7 @@ """This task sorts C/C++ includes.""" import os + import regex from wpiformat.task import PipelineTask diff --git a/wpiformat/wpiformat/licenseupdate.py b/wpiformat/wpiformat/licenseupdate.py index 5fd88f5..2175bdd 100644 --- a/wpiformat/wpiformat/licenseupdate.py +++ b/wpiformat/wpiformat/licenseupdate.py @@ -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 diff --git a/wpiformat/wpiformat/pyformat.py b/wpiformat/wpiformat/pyformat.py index 2d71064..0e98ecb 100644 --- a/wpiformat/wpiformat/pyformat.py +++ b/wpiformat/wpiformat/pyformat.py @@ -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 diff --git a/wpiformat/wpiformat/task.py b/wpiformat/wpiformat/task.py index 2b03b02..e05e94c 100644 --- a/wpiformat/wpiformat/task.py +++ b/wpiformat/wpiformat/task.py @@ -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): diff --git a/wpiformat/wpiformat/test/test_bracecomment.py b/wpiformat/wpiformat/test/test_bracecomment.py index dee620a..0ca7455 100644 --- a/wpiformat/wpiformat/test/test_bracecomment.py +++ b/wpiformat/wpiformat/test/test_bracecomment.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_cidentlist.py b/wpiformat/wpiformat/test/test_cidentlist.py index 4dbebfa..e1b84cd 100644 --- a/wpiformat/wpiformat/test/test_cidentlist.py +++ b/wpiformat/wpiformat/test/test_cidentlist.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_eofnewline.py b/wpiformat/wpiformat/test/test_eofnewline.py index 778186c..cf0c0e1 100644 --- a/wpiformat/wpiformat/test/test_eofnewline.py +++ b/wpiformat/wpiformat/test/test_eofnewline.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_gtestname.py b/wpiformat/wpiformat/test/test_gtestname.py index f0204a5..8249354 100644 --- a/wpiformat/wpiformat/test/test_gtestname.py +++ b/wpiformat/wpiformat/test/test_gtestname.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_includeguard.py b/wpiformat/wpiformat/test/test_includeguard.py index b8a7c0f..fc49653 100644 --- a/wpiformat/wpiformat/test/test_includeguard.py +++ b/wpiformat/wpiformat/test/test_includeguard.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_includeorder.py b/wpiformat/wpiformat/test/test_includeorder.py index 19290be..ebec039 100644 --- a/wpiformat/wpiformat/test/test_includeorder.py +++ b/wpiformat/wpiformat/test/test_includeorder.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_javaclass.py b/wpiformat/wpiformat/test/test_javaclass.py index c1c406b..f3161da 100644 --- a/wpiformat/wpiformat/test/test_javaclass.py +++ b/wpiformat/wpiformat/test/test_javaclass.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_jni.py b/wpiformat/wpiformat/test/test_jni.py index cfd0f33..a52461f 100644 --- a/wpiformat/wpiformat/test/test_jni.py +++ b/wpiformat/wpiformat/test/test_jni.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_licenseupdate.py b/wpiformat/wpiformat/test/test_licenseupdate.py index 41f384d..d5348c8 100644 --- a/wpiformat/wpiformat/test/test_licenseupdate.py +++ b/wpiformat/wpiformat/test/test_licenseupdate.py @@ -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): diff --git a/wpiformat/wpiformat/test/test_stdlib.py b/wpiformat/wpiformat/test/test_stdlib.py index 9416083..2e87c5b 100644 --- a/wpiformat/wpiformat/test/test_stdlib.py +++ b/wpiformat/wpiformat/test/test_stdlib.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_tasktest.py b/wpiformat/wpiformat/test/test_tasktest.py index 86c0c5a..1d55433 100644 --- a/wpiformat/wpiformat/test/test_tasktest.py +++ b/wpiformat/wpiformat/test/test_tasktest.py @@ -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 diff --git a/wpiformat/wpiformat/test/test_usingdeclaration.py b/wpiformat/wpiformat/test/test_usingdeclaration.py index 647d340..1923b21 100644 --- a/wpiformat/wpiformat/test/test_usingdeclaration.py +++ b/wpiformat/wpiformat/test/test_usingdeclaration.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_usingnamespacestd.py b/wpiformat/wpiformat/test/test_usingnamespacestd.py index 79aa034..65a5620 100644 --- a/wpiformat/wpiformat/test/test_usingnamespacestd.py +++ b/wpiformat/wpiformat/test/test_usingnamespacestd.py @@ -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()) diff --git a/wpiformat/wpiformat/test/test_whitespace.py b/wpiformat/wpiformat/test/test_whitespace.py index a9ade0e..fc64348 100644 --- a/wpiformat/wpiformat/test/test_whitespace.py +++ b/wpiformat/wpiformat/test/test_whitespace.py @@ -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()) diff --git a/wpiformat/wpiformat/version.py b/wpiformat/wpiformat/version.py index 6953c61..e5857ba 100644 --- a/wpiformat/wpiformat/version.py +++ b/wpiformat/wpiformat/version.py @@ -1,5 +1,5 @@ -from datetime import date import subprocess +from datetime import date def get_version():