Skip to content

Commit 75d464d

Browse files
committed
chore: automatically format code using isort and black
1 parent 52af91c commit 75d464d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

noxfile.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import nox
1717
import shutil
1818

19+
BLACK_VERSION = "black==22.3.0"
20+
ISORT_VERSION = "isort==5.10.1"
21+
1922
test_dependencies = [
2023
"django>=2.0.0",
2124
"google-auth",
@@ -44,6 +47,24 @@ def lint(session):
4447
"--statistics",
4548
)
4649

50+
@nox.session(python="3.8")
51+
def format(session):
52+
"""
53+
Run isort to sort imports. Then run black
54+
to format code to uniform standard.
55+
"""
56+
session.install(BLACK_VERSION, ISORT_VERSION)
57+
# Use the --fss option to sort imports using strict alphabetical order.
58+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
59+
session.run(
60+
"isort",
61+
"--fss",
62+
".",
63+
)
64+
session.run(
65+
"black",
66+
".",
67+
)
4768

4869
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"])
4970
@nox.parametrize(

owlbot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@
4343
# ----------------------------------------------------------------------------
4444

4545
python.py_samples(skip_readmes=True)
46+
47+
s.shell.run(["nox", "-s", "format"], hide_output=False)

0 commit comments

Comments
 (0)