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

Commit e03a978

Browse files
committed
fix lint
1 parent 4965011 commit e03a978

4 files changed

Lines changed: 65 additions & 28 deletions

File tree

gapic/schema/api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,6 @@ def __init__(
11091109
load_services: bool = True,
11101110
all_resources: Optional[Mapping[str, wrappers.MessageType]] = None,
11111111
context_cache: Optional[Dict] = None,
1112-
11131112
):
11141113
self.proto_messages: Dict[str, wrappers.MessageType] = {}
11151114
self.proto_enums: Dict[str, wrappers.EnumType] = {}
@@ -1235,7 +1234,12 @@ def proto(self) -> Proto:
12351234
return dataclasses.replace(
12361235
naive,
12371236
all_enums=collections.OrderedDict(
1238-
(k, v.with_context(collisions=global_collisions, context_cache=self.context_cache))
1237+
(
1238+
k,
1239+
v.with_context(
1240+
collisions=global_collisions, context_cache=self.context_cache
1241+
),
1242+
)
12391243
for k, v in naive.all_enums.items()
12401244
),
12411245
all_messages=collections.OrderedDict(
@@ -1262,7 +1266,9 @@ def proto(self) -> Proto:
12621266
)
12631267
for k, v in naive.services.items()
12641268
),
1265-
meta=naive.meta.with_context(collisions=naive.names, context_cache=self.context_cache),
1269+
meta=naive.meta.with_context(
1270+
collisions=naive.names, context_cache=self.context_cache
1271+
),
12661272
)
12671273

12681274
@cached_property

gapic/schema/metadata.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ def resolve(self, selector: str) -> str:
361361
return selector
362362

363363
@cached_proto_context
364-
def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] = None) -> "Address":
364+
def with_context(
365+
self, *, collisions: Set[str], context_cache: Optional[Dict] = None
366+
) -> "Address":
365367
"""Return a derivative of this address with the provided context.
366368
367369
This method is used to address naming collisions. The returned
@@ -401,7 +403,9 @@ def doc(self):
401403
return ""
402404

403405
@cached_proto_context
404-
def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] = None) -> "Metadata":
406+
def with_context(
407+
self, *, collisions: Set[str], context_cache: Optional[Dict] = None
408+
) -> "Metadata":
405409
"""Return a derivative of this metadata with the provided context.
406410
407411
This method is used to address naming collisions. The returned
@@ -411,7 +415,9 @@ def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] =
411415
return (
412416
dataclasses.replace(
413417
self,
414-
address=self.address.with_context(collisions=collisions, context_cache=context_cache),
418+
address=self.address.with_context(
419+
collisions=collisions, context_cache=context_cache
420+
),
415421
)
416422
if collisions and collisions != self.address.collisions
417423
else self

gapic/schema/wrappers.py

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,21 @@ def with_context(
434434
self.message in visited_messages if visited_messages else False
435435
),
436436
visited_messages=visited_messages,
437-
context_cache=context_cache
437+
context_cache=context_cache,
438438
)
439439
if self.message
440440
else None
441441
),
442-
enum=self.enum.with_context(collisions=collisions, context_cache=context_cache) if self.enum else None,
443-
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
442+
enum=(
443+
self.enum.with_context(
444+
collisions=collisions, context_cache=context_cache
445+
)
446+
if self.enum
447+
else None
448+
),
449+
meta=self.meta.with_context(
450+
collisions=collisions, context_cache=context_cache
451+
),
444452
)
445453

446454
def add_to_address_allowlist(
@@ -741,7 +749,10 @@ def path_regex_str(self) -> str:
741749
return parsing_regex_str
742750

743751
def get_field(
744-
self, *field_path: str, context_cache: Optional[Dict] = None, collisions: Optional[Set[str]] = None
752+
self,
753+
*field_path: str,
754+
context_cache: Optional[Dict] = None,
755+
collisions: Optional[Set[str]] = None,
745756
) -> Field:
746757
"""Return a field arbitrarily deep in this message's structure.
747758
@@ -836,7 +847,9 @@ def with_context(
836847
fields=(
837848
{
838849
k: v.with_context(
839-
collisions=collisions, visited_messages=visited_messages, context_cache=context_cache
850+
collisions=collisions,
851+
visited_messages=visited_messages,
852+
context_cache=context_cache,
840853
)
841854
for k, v in self.fields.items()
842855
}
@@ -852,11 +865,13 @@ def with_context(
852865
collisions=collisions,
853866
skip_fields=skip_fields,
854867
visited_messages=visited_messages,
855-
context_cache=context_cache
868+
context_cache=context_cache,
856869
)
857870
for k, v in self.nested_messages.items()
858871
},
859-
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
872+
meta=self.meta.with_context(
873+
collisions=collisions, context_cache=context_cache
874+
),
860875
)
861876

862877
def add_to_address_allowlist(
@@ -946,7 +961,12 @@ def ident(self) -> metadata.Address:
946961
return self.meta.address
947962

948963
@cached_proto_context
949-
def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] = None,) -> "EnumType":
964+
def with_context(
965+
self,
966+
*,
967+
collisions: Set[str],
968+
context_cache: Optional[Dict] = None,
969+
) -> "EnumType":
950970
"""Return a derivative of this enum with the provided context.
951971
952972
This method is used to address naming collisions. The returned
@@ -956,7 +976,9 @@ def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] =
956976
return (
957977
dataclasses.replace(
958978
self,
959-
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
979+
meta=self.meta.with_context(
980+
collisions=collisions, context_cache=context_cache
981+
),
960982
)
961983
if collisions
962984
else self
@@ -1089,12 +1111,12 @@ def with_context(
10891111
request_type=self.request_type.with_context(
10901112
collisions=collisions,
10911113
visited_messages=visited_messages,
1092-
context_cache=context_cache
1114+
context_cache=context_cache,
10931115
),
10941116
operation_type=self.operation_type.with_context(
10951117
collisions=collisions,
10961118
visited_messages=visited_messages,
1097-
context_cache=context_cache
1119+
context_cache=context_cache,
10981120
),
10991121
)
11001122
)
@@ -1159,12 +1181,12 @@ def with_context(
11591181
response_type=self.response_type.with_context(
11601182
collisions=collisions,
11611183
visited_messages=visited_messages,
1162-
context_cache=context_cache
1184+
context_cache=context_cache,
11631185
),
11641186
metadata_type=self.metadata_type.with_context(
11651187
collisions=collisions,
11661188
visited_messages=visited_messages,
1167-
context_cache=context_cache
1189+
context_cache=context_cache,
11681190
),
11691191
)
11701192

@@ -1974,7 +1996,7 @@ def with_context(
19741996
self.lro.with_context(
19751997
collisions=collisions,
19761998
visited_messages=visited_messages,
1977-
context_cache=context_cache
1999+
context_cache=context_cache,
19782000
)
19792001
if collisions
19802002
else self.lro
@@ -1984,7 +2006,7 @@ def with_context(
19842006
self.extended_lro.with_context(
19852007
collisions=collisions,
19862008
visited_messages=visited_messages,
1987-
context_cache=context_cache
2009+
context_cache=context_cache,
19882010
)
19892011
if self.extended_lro
19902012
else None
@@ -1997,14 +2019,16 @@ def with_context(
19972019
input=self.input.with_context(
19982020
collisions=collisions,
19992021
visited_messages=visited_messages,
2000-
context_cache=context_cache
2022+
context_cache=context_cache,
20012023
),
20022024
output=self.output.with_context(
20032025
collisions=collisions,
20042026
visited_messages=visited_messages,
2005-
context_cache=context_cache
2027+
context_cache=context_cache,
2028+
),
2029+
meta=self.meta.with_context(
2030+
collisions=collisions, context_cache=context_cache
20062031
),
2007-
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
20082032
)
20092033

20102034
def add_to_address_allowlist(
@@ -2402,11 +2426,13 @@ def with_context(
24022426
# that may conflict with module imports.
24032427
collisions=collisions | set(v.flattened_fields.keys()),
24042428
visited_messages=visited_messages,
2405-
context_cache=context_cache
2429+
context_cache=context_cache,
24062430
)
24072431
for k, v in self.methods.items()
24082432
},
2409-
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
2433+
meta=self.meta.with_context(
2434+
collisions=collisions, context_cache=context_cache
2435+
),
24102436
)
24112437

24122438
def add_to_address_allowlist(

gapic/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535

3636
__all__ = (
3737
"cached_property",
38-
"cached_proto_context"
39-
"convert_uri_fieldnames",
38+
"cached_proto_context" "convert_uri_fieldnames",
4039
"doc",
4140
"empty",
4241
"is_msg_field_pb",

0 commit comments

Comments
 (0)