Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 58ccf79

Browse files
committed
nox -s blacken
1 parent 8d4d698 commit 58ccf79

File tree

18 files changed

+83
-98
lines changed

18 files changed

+83
-98
lines changed

docs/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
# Replace |version| in the docs with the actual version string.
3333
rst_epilog = """
3434
.. |version| replace:: {version}
35-
""".format(
36-
version=version
37-
)
35+
""".format(version=version)
3836

3937
# -- General configuration ---------------------------------------------------
4038

gapic/cli/generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"--output",
3939
type=click.File("wb"),
4040
default=sys.stdout.buffer,
41-
help="Where to output the `CodeGeneratorResponse`. " "Defaults to stdout.",
41+
help="Where to output the `CodeGeneratorResponse`. Defaults to stdout.",
4242
)
4343
def generate(request: typing.BinaryIO, output: typing.BinaryIO) -> None:
4444
"""Generate a full API client description."""

gapic/generator/generator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ def get_response(self, api_schema: api.API, opts: Options) -> CodeGeneratorRespo
131131
)
132132

133133
# Return the CodeGeneratorResponse output.
134-
res = CodeGeneratorResponse(
135-
file=[i for i in output_files.values()]
136-
) # type: ignore
134+
res = CodeGeneratorResponse(file=[i for i in output_files.values()]) # type: ignore
137135
res.supported_features |= CodeGeneratorResponse.Feature.FEATURE_PROTO3_OPTIONAL # type: ignore
138136
return res
139137

gapic/samplegen_utils/snippet_index.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ def __init__(self, api_schema: api.API):
117117
self.metadata_index.client_library.name = (
118118
api_schema.naming.warehouse_package_name
119119
)
120-
self.metadata_index.client_library.language = snippet_metadata_pb2.Language.PYTHON # type: ignore
120+
self.metadata_index.client_library.language = (
121+
snippet_metadata_pb2.Language.PYTHON
122+
) # type: ignore
121123

122124
self.metadata_index.client_library.version = api_schema.gapic_version
123125

gapic/samplegen_utils/yaml.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ def get(self, key, default=None):
116116
return next(
117117
iter(
118118
[
119-
e.val for e in self.elements if e.key == key # type: ignore
119+
e.val
120+
for e in self.elements
121+
if e.key == key # type: ignore
120122
] # type: ignore
121123
),
122124
default,

gapic/schema/api.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -941,11 +941,7 @@ def enforce_valid_library_settings(
941941
selective_gapic_errors = {}
942942
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2446):
943943
# Workaround issue in Python 3.14 related to code coverage by adding `# pragma: no branch`
944-
for (
945-
method_name
946-
) in (
947-
library_settings.python_settings.common.selective_gapic_generation.methods
948-
): # pragma: no branch
944+
for method_name in library_settings.python_settings.common.selective_gapic_generation.methods: # pragma: no branch
949945
if method_name not in self.all_methods:
950946
selective_gapic_errors[method_name] = "Method does not exist."
951947
elif not method_name.startswith(library_settings.version):
@@ -1180,8 +1176,7 @@ def __init__(
11801176
object.__setattr__(field, "enum", maybe_enum_type)
11811177
else:
11821178
raise TypeError(
1183-
f"Unknown type referenced in "
1184-
f"{self.file_descriptor.name}: '{key}'"
1179+
f"Unknown type referenced in {self.file_descriptor.name}: '{key}'"
11851180
)
11861181

11871182
# Only generate the service if this is a target file to be generated.

gapic/schema/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def resolve(self, selector: str) -> str:
356356
str: An absolute selector.
357357
"""
358358
if "." not in selector:
359-
return f'{".".join(self.package)}.{selector}'
359+
return f"{'.'.join(self.package)}.{selector}"
360360
return selector
361361

362362
def with_context(self, *, collisions: Set[str]) -> "Address":

gapic/schema/naming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def build(
8686
"The protos provided do not share a common root package. "
8787
"Ensure that all explicitly-specified protos are for a "
8888
"single API. "
89-
f'The packages we got are: {", ".join(proto_packages)}'
89+
f"The packages we got are: {', '.join(proto_packages)}"
9090
)
9191

9292
# Define the valid regex to split the package.

gapic/schema/wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def get_field(
797797
# Quick check: If this cursor has no message, there is a problem.
798798
if not cursor.message:
799799
raise KeyError(
800-
f'Field {".".join(field_path)} could not be resolved from '
800+
f"Field {'.'.join(field_path)} could not be resolved from "
801801
f"{cursor.name}.",
802802
)
803803

noxfile.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def unit(session):
6767
"grpcio-status",
6868
"proto-plus",
6969
)
70-
session.install("-e", ".")
70+
# session.install("-e", ".")
7171
session.run(
7272
"py.test",
7373
*(
@@ -82,6 +82,7 @@ def unit(session):
8282
path.join("tests", "unit"),
8383
]
8484
),
85+
external=True,
8586
)
8687

8788

@@ -296,7 +297,7 @@ def showcase_library(
296297
}
297298
]
298299
update_service_yaml = _add_python_settings(tmp_dir, python_settings)
299-
session.run("python", "-c" f"{update_service_yaml}")
300+
session.run("python", f"-c{update_service_yaml}")
300301
# END TODO section to remove.
301302
if retry_config:
302303
session.run(
@@ -765,7 +766,8 @@ def lint(session):
765766
"format",
766767
"--check",
767768
*LINT_PATHS,
768-
"--exclude", RUFF_EXCLUDES,
769+
"--exclude",
770+
RUFF_EXCLUDES,
769771
)
770772

771773
# 3. Run Flake8
@@ -779,22 +781,25 @@ def lint(session):
779781
@nox.session(python="3.10")
780782
def blacken(session):
781783
"""Run ruff format.
782-
784+
783785
DEPRECATED: This session now uses Ruff instead of Black.
784786
It formats code style only (indentation, quotes, etc).
785787
"""
786-
session.log("WARNING: The 'blacken' session is deprecated and will be removed in the next release. Please use 'nox -s format' in the future.")
787-
788-
788+
session.log(
789+
"WARNING: The 'blacken' session is deprecated and will be removed in the next release. Please use 'nox -s format' in the future."
790+
)
791+
789792
session.install(RUFF_VERSION)
790-
793+
791794
# 1. Format Code (Replaces black)
792795
# We do NOT run 'ruff check --select I' here, preserving strict parity.
793796
session.run(
794797
"ruff",
795798
"format",
799+
"--line-length=88", # Standard Black line length
796800
*LINT_PATHS,
797-
"--exclude", RUFF_EXCLUDES,
801+
"--exclude",
802+
RUFF_EXCLUDES,
798803
)
799804

800805

0 commit comments

Comments
 (0)