Commit 62646ba 1 parent 0774515 commit 62646ba Copy full SHA for 62646ba
File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 30
30
# WARNING - WARNING - WARNING - WARNING - WARNING
31
31
32
32
BLACK_VERSION = "black==22.3.0"
33
+ ISORT_VERSION = "isort==5.10.1"
33
34
34
35
# Copy `noxfile_config.py` to your directory and modify it instead.
35
36
@@ -168,12 +169,32 @@ def lint(session: nox.sessions.Session) -> None:
168
169
169
170
@nox .session
170
171
def blacken (session : nox .sessions .Session ) -> None :
172
+ """Run black. Format code to uniform standard."""
171
173
session .install (BLACK_VERSION )
172
174
python_files = [path for path in os .listdir ("." ) if path .endswith (".py" )]
173
175
174
176
session .run ("black" , * python_files )
175
177
176
178
179
+ #
180
+ # format = isort + black
181
+ #
182
+
183
+ @nox .session
184
+ def format (session : nox .sessions .Session ) -> None :
185
+ """
186
+ Run isort to sort imports. Then run black
187
+ to format code to uniform standard.
188
+ """
189
+ session .install (BLACK_VERSION , ISORT_VERSION )
190
+ python_files = [path for path in os .listdir ("." ) if path .endswith (".py" )]
191
+
192
+ # Use the --fss option to sort imports using strict alphabetical order.
193
+ # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
194
+ session .run ("isort" , "--fss" , * python_files )
195
+ session .run ("black" , * python_files )
196
+
197
+
177
198
#
178
199
# Sample Tests
179
200
#
Original file line number Diff line number Diff line change 30
30
# WARNING - WARNING - WARNING - WARNING - WARNING
31
31
32
32
BLACK_VERSION = "black==22.3.0"
33
+ ISORT_VERSION = "isort==5.10.1"
33
34
34
35
# Copy `noxfile_config.py` to your directory and modify it instead.
35
36
@@ -168,12 +169,32 @@ def lint(session: nox.sessions.Session) -> None:
168
169
169
170
@nox .session
170
171
def blacken (session : nox .sessions .Session ) -> None :
172
+ """Run black. Format code to uniform standard."""
171
173
session .install (BLACK_VERSION )
172
174
python_files = [path for path in os .listdir ("." ) if path .endswith (".py" )]
173
175
174
176
session .run ("black" , * python_files )
175
177
176
178
179
+ #
180
+ # format = isort + black
181
+ #
182
+
183
+ @nox .session
184
+ def format (session : nox .sessions .Session ) -> None :
185
+ """
186
+ Run isort to sort imports. Then run black
187
+ to format code to uniform standard.
188
+ """
189
+ session .install (BLACK_VERSION , ISORT_VERSION )
190
+ python_files = [path for path in os .listdir ("." ) if path .endswith (".py" )]
191
+
192
+ # Use the --fss option to sort imports using strict alphabetical order.
193
+ # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
194
+ session .run ("isort" , "--fss" , * python_files )
195
+ session .run ("black" , * python_files )
196
+
197
+
177
198
#
178
199
# Sample Tests
179
200
#
You can’t perform that action at this time.
0 commit comments