3131
3232import nox
3333
34- FLAKE8_VERSION = "flake8==6.1.0"
35- BLACK_VERSION = "black[jupyter]==23.7.0"
36- ISORT_VERSION = "isort==5.11.0"
3734RUFF_VERSION = "ruff==0.14.14"
3835LINT_PATHS = ["google" , "tests" , "noxfile.py" , "setup.py" ]
3936
@@ -116,40 +113,37 @@ def lint(session):
116113 Returns a failure if the linters find linting errors or sufficiently
117114 serious code quality issues.
118115 """
119- session .install (FLAKE8_VERSION , RUFF_VERSION )
120- # Check formatting
116+ session .install ("flake8" , RUFF_VERSION )
117+
118+ # 2. Check formatting
121119 session .run (
122- "ruff" ,
123- "format" ,
120+ "ruff" , "format" ,
124121 "--check" ,
125122 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
126- "--line-length=88" ,
123+ "--line-length=88" ,
127124 * LINT_PATHS ,
128125 )
129126
130- session .run ("flake8" , "google" , "tests" )
131-
132127
133128# Use a python runtime which is available in the owlbot post processor here
134129# https://github.com/googleapis/synthtool/blob/master/docker/owlbot/python/Dockerfile
135130@nox .session (python = DEFAULT_PYTHON_VERSION )
136131def blacken (session ):
137132 """(Deprecated) Legacy session. Please use 'nox -s format'."""
138- session .log (
139- "WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future."
140- )
133+ session .log ("WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future." )
134+
135+ # Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports )
141136 session .install (RUFF_VERSION )
142137 session .run (
143- "ruff" ,
144- "format" ,
138+ "ruff" , "format" ,
145139 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
146140 "--line-length=88" ,
147141 * LINT_PATHS ,
148142 )
149143
150144
151- @nox .session
152- def format (session : nox . sessions . Session ) -> None :
145+ @nox .session ( python = DEFAULT_PYTHON_VERSION )
146+ def format (session ) :
153147 """
154148 Run ruff to sort imports and format code.
155149 """
@@ -160,10 +154,8 @@ def format(session: nox.sessions.Session) -> None:
160154 # check --select I: Enables strict import sorting
161155 # --fix: Applies the changes automatically
162156 session .run (
163- "ruff" ,
164- "check" ,
165- "--select" ,
166- "I" ,
157+ "ruff" , "check" ,
158+ "--select" , "I" ,
167159 "--fix" ,
168160 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
169161 "--line-length=88" , # Standard Black line length
@@ -172,18 +164,18 @@ def format(session: nox.sessions.Session) -> None:
172164
173165 # 3. Run Ruff to format code
174166 session .run (
175- "ruff" ,
176- "format" ,
167+ "ruff" , "format" ,
177168 f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
178169 "--line-length=88" , # Standard Black line length
179170 * LINT_PATHS ,
180171 )
181172
182173
174+
183175@nox .session (python = DEFAULT_PYTHON_VERSION )
184176def lint_setup_py (session ):
185177 """Verify that setup.py is valid (including RST check)."""
186- session .install ("docutils " , "pygments " , "setuptools>=79.0.1 " )
178+ session .install ("setuptools " , "docutils " , "pygments " )
187179 session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
188180
189181
0 commit comments