2626BLACK_VERSION = "black[jupyter]==23.7.0"
2727ISORT_VERSION = "isort==5.11.0"
2828
29+ FORMAT_PATHS = ["docs" , "google" , "tests" , "setup.py" ]
2930LINT_PATHS = ["docs" , "google" , "tests" , "noxfile.py" , "setup.py" ]
3031
32+ # We're most interested in ensuring that code is formatted properly
33+ # and less concerned about the line length.
34+ LINT_LINE_LENGTH = 150
35+
3136# Add samples to the list of directories to format if the directory exists.
3237if os .path .isdir ("samples" ):
3338 LINT_PATHS .append ("samples" )
39+ FORMAT_PATHS .append ("samples" )
3440
3541ALL_PYTHON = [
3642 "3.7" ,
@@ -155,6 +161,7 @@ def lint(session):
155161 "black" ,
156162 "--check" ,
157163 * LINT_PATHS ,
164+ f"--line-length={ LINT_LINE_LENGTH } " ,
158165 )
159166
160167 session .run ("flake8" , "google" , "tests" )
@@ -166,7 +173,8 @@ def blacken(session):
166173 session .install (BLACK_VERSION )
167174 session .run (
168175 "black" ,
169- * LINT_PATHS ,
176+ * FORMAT_PATHS ,
177+ f"--line-length={ LINT_LINE_LENGTH } " ,
170178 )
171179
172180
@@ -182,11 +190,12 @@ def format(session):
182190 session .run (
183191 "isort" ,
184192 "--fss" ,
185- * LINT_PATHS ,
193+ * FORMAT_PATHS ,
186194 )
187195 session .run (
188196 "black" ,
189- * LINT_PATHS ,
197+ * FORMAT_PATHS ,
198+ f"--line-length={ LINT_LINE_LENGTH } " ,
190199 )
191200
192201
@@ -203,8 +212,7 @@ def install_unittest_dependencies(session, *constraints):
203212
204213 if UNIT_TEST_EXTERNAL_DEPENDENCIES :
205214 warnings .warn (
206- "'unit_test_external_dependencies' is deprecated. Instead, please "
207- "use 'unit_test_dependencies' or 'unit_test_local_dependencies'." ,
215+ "'unit_test_external_dependencies' is deprecated. Instead, please use 'unit_test_dependencies' or 'unit_test_local_dependencies'." ,
208216 DeprecationWarning ,
209217 )
210218 session .install (* UNIT_TEST_EXTERNAL_DEPENDENCIES , * constraints )
@@ -235,12 +243,15 @@ def unit(session, protobuf_implementation):
235243
236244 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
237245 # Remove this check once support for Protobuf 3.x is dropped.
238- if protobuf_implementation == "cpp" and session .python in ("3.11" , "3.12" , "3.13" , "3.14" ):
246+ if protobuf_implementation == "cpp" and session .python in (
247+ "3.11" ,
248+ "3.12" ,
249+ "3.13" ,
250+ "3.14" ,
251+ ):
239252 session .skip ("cpp implementation is not supported in python 3.11+" )
240253
241- constraints_path = str (
242- CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
243- )
254+ constraints_path = str (CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt" )
244255 install_unittest_dependencies (session , "-c" , constraints_path )
245256
246257 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
@@ -298,9 +309,7 @@ def install_systemtest_dependencies(session, *constraints):
298309@nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
299310def system (session ):
300311 """Run the system test suite."""
301- constraints_path = str (
302- CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
303- )
312+ constraints_path = str (CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt" )
304313 system_test_path = os .path .join ("tests" , "system.py" )
305314 system_test_folder_path = os .path .join ("tests" , "system" )
306315
@@ -377,8 +386,10 @@ def docs(session):
377386 "-W" , # warnings as errors
378387 "-T" , # show full traceback on exception
379388 "-N" , # no colors
380- "-b" , "html" , # builder
381- "-d" , os .path .join ("docs" , "_build" , "doctrees" , "" ), # cache directory
389+ "-b" , # builder
390+ "html" ,
391+ "-d" , # cache directory
392+ os .path .join ("docs" , "_build" , "doctrees" , "" ),
382393 # paths to build:
383394 os .path .join ("docs" , "" ),
384395 os .path .join ("docs" , "_build" , "html" , "" ),
@@ -446,7 +457,12 @@ def prerelease_deps(session, protobuf_implementation):
446457
447458 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
448459 # Remove this check once support for Protobuf 3.x is dropped.
449- if protobuf_implementation == "cpp" and session .python in ("3.11" , "3.12" , "3.13" , "3.14" ):
460+ if protobuf_implementation == "cpp" and session .python in (
461+ "3.11" ,
462+ "3.12" ,
463+ "3.13" ,
464+ "3.14" ,
465+ ):
450466 session .skip ("cpp implementation is not supported in python 3.11+" )
451467
452468 # Install all dependencies
@@ -457,11 +473,7 @@ def prerelease_deps(session, protobuf_implementation):
457473 session .install (* unit_deps_all )
458474
459475 # Install dependencies for the system test environment
460- system_deps_all = (
461- SYSTEM_TEST_STANDARD_DEPENDENCIES
462- + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
463- + SYSTEM_TEST_EXTRAS
464- )
476+ system_deps_all = SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + SYSTEM_TEST_EXTRAS
465477 session .install (* system_deps_all )
466478
467479 # Because we test minimum dependency versions on the minimum Python
@@ -473,13 +485,8 @@ def prerelease_deps(session, protobuf_implementation):
473485 ) as constraints_file :
474486 constraints_text = constraints_file .read ()
475487
476- # Ignore leading whitespace and comment lines.
477- constraints_deps = [
478- match .group (1 )
479- for match in re .finditer (
480- r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE
481- )
482- ]
488+ # Ignore leading spaces and comment lines.
489+ constraints_deps = [match .group (1 ) for match in re .finditer (r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE )]
483490
484491 # Install dependencies specified in `testing/constraints-X.txt`.
485492 session .install (* constraints_deps )
@@ -550,11 +557,7 @@ def core_deps_from_source(session, protobuf_implementation):
550557 session .install (* unit_deps_all )
551558
552559 # Install dependencies for the system test environment
553- system_deps_all = (
554- SYSTEM_TEST_STANDARD_DEPENDENCIES
555- + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
556- + SYSTEM_TEST_EXTRAS
557- )
560+ system_deps_all = SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + SYSTEM_TEST_EXTRAS
558561 session .install (* system_deps_all )
559562
560563 # Because we test minimum dependency versions on the minimum Python
@@ -566,13 +569,8 @@ def core_deps_from_source(session, protobuf_implementation):
566569 ) as constraints_file :
567570 constraints_text = constraints_file .read ()
568571
569- # Ignore leading whitespace and comment lines.
570- constraints_deps = [
571- match .group (1 )
572- for match in re .finditer (
573- r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE
574- )
575- ]
572+ # Ignore leading spaces and comment lines.
573+ constraints_deps = [match .group (1 ) for match in re .finditer (r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE )]
576574
577575 # Install dependencies specified in `testing/constraints-X.txt`.
578576 session .install (* constraints_deps )
0 commit comments