Skip to content

Commit 998a96a

Browse files
committed
fix formatting/update goldens
1 parent 3698497 commit 998a96a

File tree

9 files changed

+291
-309
lines changed

9 files changed

+291
-309
lines changed

gapic/templates/noxfile.py.j2

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ FORMAT_PATHS = ["docs", "{{ api.naming.versioned_module_name }}", "tests", "setu
2323
LINT_PATHS = ["docs", "{{ api.naming.versioned_module_name }}", "tests", "noxfile.py", "setup.py"]
2424
{% endif %}
2525

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+
2630
# Add samples to the list of directories to format if the directory exists.
2731
if os.path.isdir("samples"):
2832
LINT_PATHS.append("samples")
@@ -155,6 +159,7 @@ def lint(session):
155159
"black",
156160
"--check",
157161
*LINT_PATHS,
162+
f"--line-length={LINT_LINE_LENGTH}",
158163
)
159164
160165
{% if api.naming.module_namespace %}
@@ -171,6 +176,7 @@ def blacken(session):
171176
session.run(
172177
"black",
173178
*FORMAT_PATHS,
179+
f"--line-length={LINT_LINE_LENGTH}",
174180
)
175181

176182

@@ -191,6 +197,7 @@ def format(session):
191197
session.run(
192198
"black",
193199
*FORMAT_PATHS,
200+
f"--line-length={LINT_LINE_LENGTH}",
194201
)
195202

196203

@@ -207,8 +214,7 @@ def install_unittest_dependencies(session, *constraints):
207214

208215
if UNIT_TEST_EXTERNAL_DEPENDENCIES:
209216
warnings.warn(
210-
"'unit_test_external_dependencies' is deprecated. Instead, please "
211-
"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'.",
212218
DeprecationWarning,
213219
)
214220
session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints)
@@ -239,12 +245,15 @@ def unit(session, protobuf_implementation):
239245

240246
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
241247
# Remove this check once support for Protobuf 3.x is dropped.
242-
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+
):
243254
session.skip("cpp implementation is not supported in python 3.11+")
244255

245-
constraints_path = str(
246-
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
247-
)
256+
constraints_path = str(CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt")
248257
install_unittest_dependencies(session, "-c", constraints_path)
249258

250259
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
@@ -307,9 +316,7 @@ def install_systemtest_dependencies(session, *constraints):
307316
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
308317
def system(session):
309318
"""Run the system test suite."""
310-
constraints_path = str(
311-
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
312-
)
319+
constraints_path = str(CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt")
313320
system_test_path = os.path.join("tests", "system.py")
314321
system_test_folder_path = os.path.join("tests", "system")
315322

@@ -386,8 +393,10 @@ def docs(session):
386393
"-W", # warnings as errors
387394
"-T", # show full traceback on exception
388395
"-N", # no colors
389-
"-b", "html", # builder
390-
"-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", ""),
391400
# paths to build:
392401
os.path.join("docs", ""),
393402
os.path.join("docs", "_build", "html", ""),
@@ -455,7 +464,12 @@ def prerelease_deps(session, protobuf_implementation):
455464

456465
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
457466
# Remove this check once support for Protobuf 3.x is dropped.
458-
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+
):
459473
session.skip("cpp implementation is not supported in python 3.11+")
460474

461475
# Install all dependencies
@@ -466,11 +480,7 @@ def prerelease_deps(session, protobuf_implementation):
466480
session.install(*unit_deps_all)
467481

468482
# Install dependencies for the system test environment
469-
system_deps_all = (
470-
SYSTEM_TEST_STANDARD_DEPENDENCIES
471-
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES
472-
+ SYSTEM_TEST_EXTRAS
473-
)
483+
system_deps_all = SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + SYSTEM_TEST_EXTRAS
474484
session.install(*system_deps_all)
475485

476486
# Because we test minimum dependency versions on the minimum Python
@@ -482,13 +492,8 @@ def prerelease_deps(session, protobuf_implementation):
482492
) as constraints_file:
483493
constraints_text = constraints_file.read()
484494

485-
# Ignore leading whitespace and comment lines.
486-
constraints_deps = [
487-
match.group(1)
488-
for match in re.finditer(
489-
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
490-
)
491-
]
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)]
492497

493498
# Install dependencies specified in `testing/constraints-X.txt`.
494499
session.install(*constraints_deps)
@@ -559,11 +564,7 @@ def core_deps_from_source(session, protobuf_implementation):
559564
session.install(*unit_deps_all)
560565

561566
# Install dependencies for the system test environment
562-
system_deps_all = (
563-
SYSTEM_TEST_STANDARD_DEPENDENCIES
564-
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES
565-
+ SYSTEM_TEST_EXTRAS
566-
)
567+
system_deps_all = SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + SYSTEM_TEST_EXTRAS
567568
session.install(*system_deps_all)
568569

569570
# Because we test minimum dependency versions on the minimum Python
@@ -575,13 +576,8 @@ def core_deps_from_source(session, protobuf_implementation):
575576
) as constraints_file:
576577
constraints_text = constraints_file.read()
577578

578-
# Ignore leading whitespace and comment lines.
579-
constraints_deps = [
580-
match.group(1)
581-
for match in re.finditer(
582-
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
583-
)
584-
]
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)]
585581

586582
# Install dependencies specified in `testing/constraints-X.txt`.
587583
session.install(*constraints_deps)

tests/integration/goldens/asset/BUILD.bazel

100644100755
File mode changed.

tests/integration/goldens/asset/noxfile.py

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@
2626
BLACK_VERSION = "black[jupyter]==23.7.0"
2727
ISORT_VERSION = "isort==5.11.0"
2828

29+
FORMAT_PATHS = ["docs", "google", "tests", "setup.py"]
2930
LINT_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.
3237
if os.path.isdir("samples"):
3338
LINT_PATHS.append("samples")
39+
FORMAT_PATHS.append("samples")
3440

3541
ALL_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)
299310
def 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

Comments
 (0)