2626import pathlib
2727import re
2828import shutil
29- from typing import Dict , List
3029import warnings
30+ from typing import Dict , List
3131
3232import nox
3333
@@ -148,22 +148,34 @@ def blacken(session):
148148 )
149149
150150
151- @nox .session ( python = DEFAULT_PYTHON_VERSION )
152- def format (session ) :
151+ @nox .session
152+ def format (session : nox . sessions . Session ) -> None :
153153 """
154- Run isort to sort imports. Then run black
155- to format code to uniform standard.
154+ Run ruff to sort imports and format code.
156155 """
157- session .install (BLACK_VERSION , ISORT_VERSION )
158- # Use the --fss option to sort imports using strict alphabetical order.
159- # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
156+ # 1. Install ruff (skipped automatically if you run with --no-venv)
157+ session .install (RUFF_VERSION )
158+
159+ # 2. Run Ruff to fix imports
160+ # check --select I: Enables strict import sorting
161+ # --fix: Applies the changes automatically
160162 session .run (
161- "isort" ,
162- "--fss" ,
163+ "ruff" ,
164+ "check" ,
165+ "--select" ,
166+ "I" ,
167+ "--fix" ,
168+ f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
169+ "--line-length=88" , # Standard Black line length
163170 * LINT_PATHS ,
164171 )
172+
173+ # 3. Run Ruff to format code
165174 session .run (
166- "black" ,
175+ "ruff" ,
176+ "format" ,
177+ f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
178+ "--line-length=88" , # Standard Black line length
167179 * LINT_PATHS ,
168180 )
169181
@@ -651,17 +663,11 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
651663 )
652664
653665
654- @nox .session (python = DEFAULT_PYTHON_VERSION )
655- def mypy (session ):
656- """Run the type checker."""
657- # TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
658- # Add mypy tests
659- session .skip ("mypy tests are not yet supported" )
660-
661-
662666@nox .session (python = ALL_PYTHON )
663667def mypy (session ):
664668 """Run the type checker."""
669+ session .skip ("Mypy is not yet supported" )
670+
665671 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2579):
666672 # use the latest version of mypy
667673 session .install (
@@ -674,7 +680,7 @@ def mypy(session):
674680 "mypy" ,
675681 "-p" ,
676682 "google" ,
677- "--check-untyped-defs" ,
683+ # "--check-untyped-defs",
678684 * session .posargs ,
679685 )
680686
@@ -687,34 +693,3 @@ def core_deps_from_source(session):
687693 # TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
688694 # Add core deps from source tests
689695 session .skip ("Core deps from source tests are not yet supported" )
690-
691- @nox .session
692- def format (session : nox .sessions .Session ) -> None :
693- """
694- Run ruff to sort imports and format code.
695- """
696- # 1. Install ruff (skipped automatically if you run with --no-venv)
697- session .install (RUFF_VERSION )
698-
699- # 2. Run Ruff to fix imports
700- # check --select I: Enables strict import sorting
701- # --fix: Applies the changes automatically
702- session .run (
703- "ruff" ,
704- "check" ,
705- "--select" ,
706- "I" ,
707- "--fix" ,
708- f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
709- "--line-length=88" , # Standard Black line length
710- * LINT_PATHS ,
711- )
712-
713- # 3. Run Ruff to format code
714- session .run (
715- "ruff" ,
716- "format" ,
717- f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
718- "--line-length=88" , # Standard Black line length
719- * LINT_PATHS ,
720- )
0 commit comments