2626import pathlib
2727import re
2828import shutil
29- from typing import Dict , List
3029import warnings
30+ from typing import Dict , List
3131
3232import nox
3333
@@ -149,22 +149,34 @@ def blacken(session):
149149 )
150150
151151
152- @nox .session ( python = DEFAULT_PYTHON_VERSION )
153- def format (session ) :
152+ @nox .session
153+ def format (session : nox . sessions . Session ) -> None :
154154 """
155- Run isort to sort imports. Then run black
156- to format code to uniform standard.
155+ Run ruff to sort imports and format code.
157156 """
158- session .install (BLACK_VERSION , ISORT_VERSION )
159- # Use the --fss option to sort imports using strict alphabetical order.
160- # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
157+ # 1. Install ruff (skipped automatically if you run with --no-venv)
158+ session .install (RUFF_VERSION )
159+
160+ # 2. Run Ruff to fix imports
161+ # check --select I: Enables strict import sorting
162+ # --fix: Applies the changes automatically
161163 session .run (
162- "isort" ,
163- "--fss" ,
164+ "ruff" ,
165+ "check" ,
166+ "--select" ,
167+ "I" ,
168+ "--fix" ,
169+ f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
170+ "--line-length=88" , # Standard Black line length
164171 * LINT_PATHS ,
165172 )
173+
174+ # 3. Run Ruff to format code
166175 session .run (
167- "black" ,
176+ "ruff" ,
177+ "format" ,
178+ f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
179+ "--line-length=88" , # Standard Black line length
168180 * LINT_PATHS ,
169181 )
170182
@@ -698,17 +710,11 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
698710 )
699711
700712
701- @nox .session (python = DEFAULT_PYTHON_VERSION )
702- def mypy (session ):
703- """Run the type checker."""
704- # TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
705- # Add mypy tests
706- session .skip ("mypy tests are not yet supported" )
707-
708-
709713@nox .session (python = ALL_PYTHON )
710714def mypy (session ):
711715 """Run the type checker."""
716+ session .skip ("Mypy is not yet supported" )
717+
712718 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2579):
713719 # use the latest version of mypy
714720 session .install (
@@ -721,7 +727,7 @@ def mypy(session):
721727 "mypy" ,
722728 "-p" ,
723729 "google" ,
724- "--check-untyped-defs" ,
730+ # "--check-untyped-defs",
725731 * session .posargs ,
726732 )
727733
@@ -734,34 +740,3 @@ def core_deps_from_source(session):
734740 # TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
735741 # Add core deps from source tests
736742 session .skip ("Core deps from source tests are not yet supported" )
737-
738- @nox .session
739- def format (session : nox .sessions .Session ) -> None :
740- """
741- Run ruff to sort imports and format code.
742- """
743- # 1. Install ruff (skipped automatically if you run with --no-venv)
744- session .install (RUFF_VERSION )
745-
746- # 2. Run Ruff to fix imports
747- # check --select I: Enables strict import sorting
748- # --fix: Applies the changes automatically
749- session .run (
750- "ruff" ,
751- "check" ,
752- "--select" ,
753- "I" ,
754- "--fix" ,
755- f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
756- "--line-length=88" , # Standard Black line length
757- * LINT_PATHS ,
758- )
759-
760- # 3. Run Ruff to format code
761- session .run (
762- "ruff" ,
763- "format" ,
764- f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
765- "--line-length=88" , # Standard Black line length
766- * LINT_PATHS ,
767- )
0 commit comments