2222CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
2323
2424SYSTEM_TEST_ENV_VARS = ("GOOGLE_APPLICATION_CREDENTIALS" ,)
25- BLACK_VERSION = "black==22.3.0 "
25+ RUFF_VERSION = "ruff==0.14.14 "
2626
2727DEFAULT_PYTHON_VERSION = "3.14"
2828SYSTEM_TEST_PYTHON_VERSIONS = ["3.14" ]
@@ -188,7 +188,7 @@ def lint(session):
188188 Returns a failure if flake8 finds linting errors or sufficiently
189189 serious code quality issues.
190190 """
191- session .install ("flake8" , BLACK_VERSION )
191+ session .install ("flake8" , RUFF_VERSION )
192192 session .install ("-e" , "." )
193193 session .run (
194194 "flake8" ,
@@ -197,9 +197,14 @@ def lint(session):
197197 os .path .join ("google" , "_async_resumable_media" ),
198198 "tests_async" ,
199199 )
200+
201+ # 2. Check formatting
200202 session .run (
201- "black" ,
203+ "ruff" ,
204+ "format" ,
202205 "--check" ,
206+ f"--target-version=py{ UNIT_TEST_PYTHON_VERSIONS [0 ].replace ('.' , '' )} " ,
207+ "--line-length=88" ,
203208 os .path .join ("google" , "resumable_media" ),
204209 "tests" ,
205210 os .path .join ("google" , "_async_resumable_media" ),
@@ -216,9 +221,18 @@ def lint_setup_py(session):
216221
217222@nox .session (python = DEFAULT_PYTHON_VERSION )
218223def blacken (session ):
219- session .install (BLACK_VERSION )
224+ """(Deprecated) Legacy session. Please use 'nox -s format'."""
225+ session .log (
226+ "WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future."
227+ )
228+
229+ # Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
230+ session .install (RUFF_VERSION )
220231 session .run (
221- "black" ,
232+ "ruff" ,
233+ "format" ,
234+ f"--target-version=py{ UNIT_TEST_PYTHON_VERSIONS [0 ].replace ('.' , '' )} " ,
235+ "--line-length=88" ,
222236 os .path .join ("google" , "resumable_media" ),
223237 "tests" ,
224238 os .path .join ("google" , "_async_resumable_media" ),
0 commit comments