2626
2727import nox
2828
29- FLAKE8_VERSION = "flake8==6.1.0"
30- BLACK_VERSION = "black==23.7.0"
31- ISORT_VERSION = "isort==5.12.0"
29+
3230RUFF_VERSION = "ruff==0.14.14"
33- BLACK_PATHS = ["docs" , "google" , "tests" , "noxfile.py" , "setup.py" ]
31+
32+ LINT_PATHS = ["google" , "tests" , "noxfile.py" , "setup.py" ]
3433
3534DEFAULT_PYTHON_VERSION = "3.14"
3635UNIT_TEST_PYTHON_VERSIONS = [
@@ -82,29 +81,27 @@ def lint(session):
8281 Returns a failure if the linters find linting errors or sufficiently
8382 serious code quality issues.
8483 """
85- session .install ("flake8" , BLACK_VERSION )
84+ session .install ("flake8" , RUFF_VERSION )
85+
86+ # 2. Check formatting
8687 session .run (
87- "ruff" ,
88- "format" ,
88+ "ruff" , "format" ,
8989 "--check" ,
9090 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
91- "--line-length=88" ,
91+ "--line-length=88" ,
9292 * LINT_PATHS ,
9393 )
9494
95- session .run ("flake8" , "google" , "tests" )
96-
9795
9896@nox .session (python = DEFAULT_PYTHON_VERSION )
9997def blacken (session ):
10098 """(Deprecated) Legacy session. Please use 'nox -s format'."""
101- session .log (
102- "WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future."
103- )
99+ session .log ("WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future." )
100+
101+ # Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports )
104102 session .install (RUFF_VERSION )
105103 session .run (
106- "ruff" ,
107- "format" ,
104+ "ruff" , "format" ,
108105 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
109106 "--line-length=88" ,
110107 * LINT_PATHS ,
@@ -114,7 +111,7 @@ def blacken(session):
114111@nox .session (python = DEFAULT_PYTHON_VERSION )
115112def lint_setup_py (session ):
116113 """Verify that setup.py is valid (including RST check)."""
117- session .install ("docutils " , "pygments " , "setuptools>=79.0.1 " )
114+ session .install ("setuptools " , "docutils " , "pygments " )
118115 session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
119116
120117
@@ -526,8 +523,8 @@ def core_deps_from_source(session):
526523 session .skip ("Core deps from source tests are not yet supported" )
527524
528525
529- @nox .session
530- def format (session : nox . sessions . Session ) -> None :
526+ @nox .session ( python = DEFAULT_PYTHON_VERSION )
527+ def format (session ) :
531528 """
532529 Run ruff to sort imports and format code.
533530 """
@@ -538,10 +535,8 @@ def format(session: nox.sessions.Session) -> None:
538535 # check --select I: Enables strict import sorting
539536 # --fix: Applies the changes automatically
540537 session .run (
541- "ruff" ,
542- "check" ,
543- "--select" ,
544- "I" ,
538+ "ruff" , "check" ,
539+ "--select" , "I" ,
545540 "--fix" ,
546541 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
547542 "--line-length=88" , # Standard Black line length
@@ -550,8 +545,7 @@ def format(session: nox.sessions.Session) -> None:
550545
551546 # 3. Run Ruff to format code
552547 session .run (
553- "ruff" ,
554- "format" ,
548+ "ruff" , "format" ,
555549 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
556550 "--line-length=88" , # Standard Black line length
557551 * LINT_PATHS ,
0 commit comments