File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 1313# limitations under the License.
1414docker :
1515 image : gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16- digest : sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163
17- # created: 2022-04-06T10:30:21.687684602Z
16+ digest : sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416
17+ # created: 2022-04-20T23:42:53.970438194Z
Original file line number Diff line number Diff line change 3030# WARNING - WARNING - WARNING - WARNING - WARNING
3131
3232BLACK_VERSION = "black==22.3.0"
33+ ISORT_VERSION = "isort==5.10.1"
3334
3435# Copy `noxfile_config.py` to your directory and modify it instead.
3536
@@ -168,12 +169,32 @@ def lint(session: nox.sessions.Session) -> None:
168169
169170@nox .session
170171def blacken (session : nox .sessions .Session ) -> None :
172+ """Run black. Format code to uniform standard."""
171173 session .install (BLACK_VERSION )
172174 python_files = [path for path in os .listdir ("." ) if path .endswith (".py" )]
173175
174176 session .run ("black" , * python_files )
175177
176178
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+
177198#
178199# Sample Tests
179200#
You can’t perform that action at this time.
0 commit comments