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

Commit 40ef912

Browse files
committed
reduce diff
1 parent d6162e3 commit 40ef912

3 files changed

Lines changed: 10 additions & 38 deletions

File tree

gapic/schema/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ def proto(self) -> Proto:
12551255
k,
12561256
v.with_context(
12571257
collisions=global_collisions,
1258-
visited_messages=frozenset(v.names),
1258+
visited_messages=visited_messages,
12591259
context_cache=self.context_cache,
12601260
),
12611261
)

gapic/schema/metadata.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,12 @@ def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] =
368368
``Address`` object aliases module names to avoid naming collisions in
369369
the file being written.
370370
"""
371-
372-
updated_msg = (
371+
return (
373372
dataclasses.replace(self, collisions=collisions)
374373
if collisions and collisions != self.collisions
375374
else self
376375
)
377376

378-
return updated_msg
379-
380377

381378
@dataclasses.dataclass(frozen=True)
382379
class Metadata:
@@ -411,8 +408,7 @@ def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] =
411408
``Address`` object aliases module names to avoid naming collisions in
412409
the file being written.
413410
"""
414-
415-
updated_msg = (
411+
return (
416412
dataclasses.replace(
417413
self,
418414
address=self.address.with_context(collisions=collisions, context_cache=context_cache),
@@ -421,8 +417,6 @@ def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] =
421417
else self
422418
)
423419

424-
return updated_msg
425-
426420

427421
@dataclasses.dataclass(frozen=True)
428422
class FieldIdentifier:

gapic/schema/wrappers.py

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ def with_context(
425425
``Field`` object aliases module names to avoid naming collisions
426426
in the file being written.
427427
"""
428-
429-
updated_msg = dataclasses.replace(
428+
return dataclasses.replace(
430429
self,
431430
message=(
432431
self.message.with_context(
@@ -444,8 +443,6 @@ def with_context(
444443
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
445444
)
446445

447-
return updated_msg
448-
449446
def add_to_address_allowlist(
450447
self,
451448
*,
@@ -834,8 +831,7 @@ def with_context(
834831
"""
835832
visited_messages = visited_messages or set()
836833
visited_messages = visited_messages | {self}
837-
838-
updated_msg = dataclasses.replace(
834+
return dataclasses.replace(
839835
self,
840836
fields=(
841837
{
@@ -863,8 +859,6 @@ def with_context(
863859
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
864860
)
865861

866-
return updated_msg
867-
868862
def add_to_address_allowlist(
869863
self,
870864
*,
@@ -959,8 +953,7 @@ def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] =
959953
``EnumType`` object aliases module names to avoid naming collisions in
960954
the file being written.
961955
"""
962-
963-
updated_msg = (
956+
return (
964957
dataclasses.replace(
965958
self,
966959
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
@@ -969,8 +962,6 @@ def with_context(self, *, collisions: Set[str], context_cache: Optional[Dict] =
969962
else self
970963
)
971964

972-
return updated_msg
973-
974965
def add_to_address_allowlist(
975966
self, *, address_allowlist: Set["metadata.Address"]
976967
) -> None:
@@ -1090,8 +1081,7 @@ def with_context(
10901081
``OperationInfo`` object aliases module names to avoid naming collisions
10911082
in the file being written.
10921083
"""
1093-
1094-
updated_msg = (
1084+
return (
10951085
self
10961086
if not collisions
10971087
else dataclasses.replace(
@@ -1109,8 +1099,6 @@ def with_context(
11091099
)
11101100
)
11111101

1112-
return updated_msg
1113-
11141102
def add_to_address_allowlist(
11151103
self,
11161104
*,
@@ -1166,8 +1154,7 @@ def with_context(
11661154
``OperationInfo`` object aliases module names to avoid naming collisions
11671155
in the file being written.
11681156
"""
1169-
1170-
updated_msg = dataclasses.replace(
1157+
return dataclasses.replace(
11711158
self,
11721159
response_type=self.response_type.with_context(
11731160
collisions=collisions,
@@ -1181,9 +1168,6 @@ def with_context(
11811168
),
11821169
)
11831170

1184-
return updated_msg
1185-
1186-
11871171
def add_to_address_allowlist(
11881172
self,
11891173
*,
@@ -1984,7 +1968,6 @@ def with_context(
19841968
``Method`` object aliases module names to avoid naming collisions
19851969
in the file being written.
19861970
"""
1987-
19881971
maybe_lro = None
19891972
if self.lro:
19901973
maybe_lro = (
@@ -2007,7 +1990,7 @@ def with_context(
20071990
else None
20081991
)
20091992

2010-
updated_msg = dataclasses.replace(
1993+
return dataclasses.replace(
20111994
self,
20121995
lro=maybe_lro,
20131996
extended_lro=maybe_extended_lro,
@@ -2024,8 +2007,6 @@ def with_context(
20242007
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
20252008
)
20262009

2027-
return updated_msg
2028-
20292010
def add_to_address_allowlist(
20302011
self,
20312012
*,
@@ -2413,8 +2394,7 @@ def with_context(
24132394
``Service`` object aliases module names to avoid naming collisions
24142395
in the file being written.
24152396
"""
2416-
2417-
updated_msg = dataclasses.replace(
2397+
return dataclasses.replace(
24182398
self,
24192399
methods={
24202400
k: v.with_context(
@@ -2428,8 +2408,6 @@ def with_context(
24282408
},
24292409
meta=self.meta.with_context(collisions=collisions, context_cache=context_cache),
24302410
)
2431-
2432-
return updated_msg
24332411

24342412
def add_to_address_allowlist(
24352413
self,

0 commit comments

Comments
 (0)