@@ -16,14 +16,21 @@ BLACK_VERSION = "black[jupyter]==23.7.0"
1616ISORT_VERSION = "isort==5.11.0"
1717
1818{% if api .naming .module_namespace %}
19+ FORMAT_PATHS = ["docs", "{{ api.naming.module_namespace[0] }}", "tests", "setup.py"]
1920LINT_PATHS = ["docs", "{{ api.naming.module_namespace[0] }}", "tests", "noxfile.py", "setup.py"]
2021{% else %}
22+ FORMAT_PATHS = ["docs", "{{ api.naming.versioned_module_name }}", "tests", "setup.py"]
2123LINT_PATHS = ["docs", "{{ api.naming.versioned_module_name }}", "tests", "noxfile.py", "setup.py"]
2224{% endif %}
2325
26+ # We're most interested in ensuring that code is formatted properly
27+ # and less concerned about the line length.
28+ LINT_LINE_LENGTH = 150
29+
2430# Add samples to the list of directories to format if the directory exists.
2531if os.path.isdir("samples"):
2632 LINT_PATHS.append("samples")
33+ FORMAT_PATHS.append("samples")
2734
2835ALL_PYTHON = [
2936 "3.7",
@@ -152,6 +159,7 @@ def lint(session):
152159 " black " ,
153160 " --check " ,
154161 *LINT_PATHS,
162+ f" --line-length ={LINT_LINE_LENGTH} " ,
155163 )
156164
157165{% if api.naming.module_namespace %}
@@ -167,7 +175,8 @@ def blacken(session):
167175 session.install(BLACK_VERSION)
168176 session.run(
169177 " black" ,
170- *LINT_PATHS,
178+ *FORMAT_PATHS,
179+ f " --line-length={LINT_LINE_LENGTH}" ,
171180 )
172181
173182
@@ -183,11 +192,12 @@ def format(session):
183192 session.run(
184193 " isort" ,
185194 " --fss" ,
186- *LINT_PATHS ,
195+ *FORMAT_PATHS ,
187196 )
188197 session.run(
189198 " black" ,
190- *LINT_PATHS,
199+ *FORMAT_PATHS,
200+ f " --line-length={LINT_LINE_LENGTH}" ,
191201 )
192202
193203
@@ -204,8 +214,7 @@ def install_unittest_dependencies(session, *constraints):
204214
205215 if UNIT_TEST_EXTERNAL_DEPENDENCIES:
206216 warnings.warn(
207- " 'unit_test_external_dependencies' is deprecated. Instead, please "
208- " use 'unit_test_dependencies' or 'unit_test_local_dependencies'." ,
217+ " 'unit_test_external_dependencies' is deprecated. Instead, please use 'unit_test_dependencies' or 'unit_test_local_dependencies'." ,
209218 DeprecationWarning,
210219 )
211220 session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints)
@@ -236,12 +245,15 @@ def unit(session, protobuf_implementation):
236245
237246 # TODO(https: //github.com /googleapis /gapic-generator-python /issues /2388):
238247 # Remove this check once support for Protobuf 3.x is dropped.
239- if protobuf_implementation == " cpp" and session.python in ( " 3.11" , " 3.12" , " 3.13" , " 3.14" ):
248+ if protobuf_implementation == " cpp" and session.python in (
249+ " 3.11" ,
250+ " 3.12" ,
251+ " 3.13" ,
252+ " 3.14" ,
253+ ):
240254 session.skip( " cpp implementation is not supported in python 3.11+" )
241255
242- constraints_path = str(
243- CURRENT_DIRECTORY / " testing" / f " constraints-{session.python}.txt"
244- )
256+ constraints_path = str(CURRENT_DIRECTORY / " testing" / f " constraints-{session.python}.txt" )
245257 install_unittest_dependencies(session, " -c" , constraints_path)
246258
247259 # TODO(https: //github.com /googleapis /gapic-generator-python /issues /2388):
@@ -304,9 +316,7 @@ def install_systemtest_dependencies(session, *constraints):
304316@nox.session(python =SYSTEM_TEST_PYTHON_VERSIONS)
305317def system(session):
306318 " " " Run the system test suite." " "
307- constraints_path = str(
308- CURRENT_DIRECTORY / " testing" / f " constraints-{session.python}.txt"
309- )
319+ constraints_path = str(CURRENT_DIRECTORY / " testing" / f " constraints-{session.python}.txt" )
310320 system_test_path = os.path.join( " tests" , " system.py" )
311321 system_test_folder_path = os.path.join( " tests" , " system" )
312322
@@ -383,8 +393,10 @@ def docs(session):
383393 " -W" , # warnings as errors
384394 " -T" , # show full traceback on exception
385395 " -N" , # no colors
386- " -b" , " html" , # builder
387- " -d" , os.path.join( " docs" , " _build" , " doctrees" , " " ), # cache directory
396+ " -b" , # builder
397+ " html" ,
398+ " -d" , # cache directory
399+ os.path.join( " docs" , " _build" , " doctrees" , " " ),
388400 # paths to build:
389401 os.path.join( " docs" , " " ),
390402 os.path.join( " docs" , " _build" , " html" , " " ),
@@ -452,7 +464,12 @@ def prerelease_deps(session, protobuf_implementation):
452464
453465 # TODO(https: //github.com /googleapis /gapic-generator-python /issues /2388):
454466 # Remove this check once support for Protobuf 3.x is dropped.
455- if protobuf_implementation == " cpp" and session.python in ( " 3.11" , " 3.12" , " 3.13" , " 3.14" ):
467+ if protobuf_implementation == " cpp" and session.python in (
468+ " 3.11" ,
469+ " 3.12" ,
470+ " 3.13" ,
471+ " 3.14" ,
472+ ):
456473 session.skip( " cpp implementation is not supported in python 3.11+" )
457474
458475 # Install all dependencies
@@ -463,11 +480,7 @@ def prerelease_deps(session, protobuf_implementation):
463480 session.install(*unit_deps_all)
464481
465482 # Install dependencies for the system test environment
466- system_deps_all = (
467- SYSTEM_TEST_STANDARD_DEPENDENCIES
468- + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
469- + SYSTEM_TEST_EXTRAS
470- )
483+ system_deps_all = SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + SYSTEM_TEST_EXTRAS
471484 session.install(*system_deps_all)
472485
473486 # Because we test minimum dependency versions on the minimum Python
@@ -479,13 +492,8 @@ def prerelease_deps(session, protobuf_implementation):
479492 ) as constraints_file:
480493 constraints_text = constraints_file.read()
481494
482- # Ignore leading whitespace and comment lines.
483- constraints_deps = [
484- match.group(1)
485- for match in re.finditer(
486- r " ^\s*(\S+)(?===\S+)" , constraints_text, flags =re.MULTILINE
487- )
488- ]
495+ # Ignore leading spaces and comment lines.
496+ constraints_deps = [match.group(1) for match in re.finditer(r " ^\s*(\S+)(?===\S+)" , constraints_text, flags =re.MULTILINE)]
489497
490498 # Install dependencies specified in `testing /constraints-X.txt`.
491499 session.install(*constraints_deps)
@@ -556,11 +564,7 @@ def core_deps_from_source(session, protobuf_implementation):
556564 session.install(*unit_deps_all)
557565
558566 # Install dependencies for the system test environment
559- system_deps_all = (
560- SYSTEM_TEST_STANDARD_DEPENDENCIES
561- + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
562- + SYSTEM_TEST_EXTRAS
563- )
567+ system_deps_all = SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + SYSTEM_TEST_EXTRAS
564568 session.install(*system_deps_all)
565569
566570 # Because we test minimum dependency versions on the minimum Python
@@ -572,13 +576,8 @@ def core_deps_from_source(session, protobuf_implementation):
572576 ) as constraints_file:
573577 constraints_text = constraints_file.read()
574578
575- # Ignore leading whitespace and comment lines.
576- constraints_deps = [
577- match.group(1)
578- for match in re.finditer(
579- r " ^\s*(\S+)(?===\S+)" , constraints_text, flags =re.MULTILINE
580- )
581- ]
579+ # Ignore leading spaces and comment lines.
580+ constraints_deps = [match.group(1) for match in re.finditer(r " ^\s*(\S+)(?===\S+)" , constraints_text, flags =re.MULTILINE)]
582581
583582 # Install dependencies specified in `testing /constraints-X.txt`.
584583 session.install(*constraints_deps)
0 commit comments