2222
2323import nox
2424
25- FLAKE8_VERSION = "flake8==6.1.0"
26- BLACK_VERSION = "black==23.7.0"
27- ISORT_VERSION = "isort==5.12.0"
25+
2826RUFF_VERSION = "ruff==0.14.14"
29- BLACK_PATHS = [ "docs" , "google" , "tests" , "noxfile.py" , "setup.py" ]
27+
3028LINT_PATHS = ["google" , "tests" , "noxfile.py" , "setup.py" ]
3129
3230DEFAULT_PYTHON_VERSION = "3.14"
@@ -75,30 +73,27 @@ def lint(session):
7573 Returns a failure if the linters find linting errors or sufficiently
7674 serious code quality issues.
7775 """
78- session .install (FLAKE8_VERSION , RUFF_VERSION )
79- # Check formatting
76+ session .install ("flake8" , RUFF_VERSION )
77+
78+ # 2. Check formatting
8079 session .run (
81- "ruff" ,
82- "format" ,
80+ "ruff" , "format" ,
8381 "--check" ,
8482 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
85- "--line-length=88" ,
83+ "--line-length=88" ,
8684 * LINT_PATHS ,
8785 )
8886
89- session .run ("flake8" , "google" , "tests" )
90-
9187
9288@nox .session (python = DEFAULT_PYTHON_VERSION )
9389def blacken (session ):
9490 """(Deprecated) Legacy session. Please use 'nox -s format'."""
95- session .log (
96- "WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future."
97- )
91+ session .log ("WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future." )
92+
93+ # Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports )
9894 session .install (RUFF_VERSION )
9995 session .run (
100- "ruff" ,
101- "format" ,
96+ "ruff" , "format" ,
10297 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
10398 "--line-length=88" ,
10499 * LINT_PATHS ,
@@ -108,7 +103,7 @@ def blacken(session):
108103@nox .session (python = DEFAULT_PYTHON_VERSION )
109104def lint_setup_py (session ):
110105 """Verify that setup.py is valid (including RST check)."""
111- session .install ("docutils " , "pygments " , "setuptools>=79.0.1 " )
106+ session .install ("setuptools " , "docutils " , "pygments " )
112107 session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
113108
114109
@@ -487,8 +482,8 @@ def core_deps_from_source(session):
487482 session .skip ("Core deps from source tests are not yet supported" )
488483
489484
490- @nox .session
491- def format (session : nox . sessions . Session ) -> None :
485+ @nox .session ( python = DEFAULT_PYTHON_VERSION )
486+ def format (session ) :
492487 """
493488 Run ruff to sort imports and format code.
494489 """
@@ -499,10 +494,8 @@ def format(session: nox.sessions.Session) -> None:
499494 # check --select I: Enables strict import sorting
500495 # --fix: Applies the changes automatically
501496 session .run (
502- "ruff" ,
503- "check" ,
504- "--select" ,
505- "I" ,
497+ "ruff" , "check" ,
498+ "--select" , "I" ,
506499 "--fix" ,
507500 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
508501 "--line-length=88" , # Standard Black line length
@@ -511,8 +504,7 @@ def format(session: nox.sessions.Session) -> None:
511504
512505 # 3. Run Ruff to format code
513506 session .run (
514- "ruff" ,
515- "format" ,
507+ "ruff" , "format" ,
516508 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
517509 "--line-length=88" , # Standard Black line length
518510 * LINT_PATHS ,
0 commit comments