File tree Expand file tree Collapse file tree
packages/gapic-generator/gapic/schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -264,8 +264,18 @@ def with_selective_generation(
264264 generate_omitted_as_internal : bool ,
265265 public_methods : Set [str ],
266266 excluded_addresses : Set ["metadata.Address" ],
267- ) -> "Proto" :
267+ ) -> Optional ["Proto" ]:
268+ """Returns a version of this Proto for selective generation.
269+
270+ Args:
271+ generate_omitted_as_internal (bool): Whether to mark omitted methods as internal.
272+ public_methods (Set[str]): The set of fully-qualified method names to keep as public.
273+ excluded_addresses (Set[metadata.Address]): The set of addresses to exclude from generation.
268274
275+ Returns:
276+ Optional[Proto]: A version of this Proto with services/methods filtered.
277+ Returns None if the Proto becomes empty and generate_omitted_as_internal is False.
278+ """
269279 services = {}
270280 for k , v in self .services .items ():
271281 new_v = v .with_selective_generation (
@@ -288,7 +298,7 @@ def with_selective_generation(
288298
289299 # If the proto becomes empty after pruning, we return None to signal
290300 # that it should be excluded from generation.
291- if not services and not all_messages and not all_enums :
301+ if not generate_omitted_as_internal and not services and not all_messages and not all_enums :
292302 return None
293303
294304 return dataclasses .replace (
Original file line number Diff line number Diff line change @@ -2066,7 +2066,7 @@ def with_selective_generation(
20662066 generate_omitted_as_internal : bool ,
20672067 public_methods : Set [str ],
20682068 excluded_addresses : Set ["metadata.Address" ],
2069- ) -> "Method" :
2069+ ) -> Optional [ "Method" ] :
20702070
20712071 if self .ident .proto in public_methods :
20722072 return self
@@ -2474,7 +2474,7 @@ def with_selective_generation(
24742474 generate_omitted_as_internal : bool ,
24752475 public_methods : Set [str ],
24762476 excluded_addresses : Set ["metadata.Address" ],
2477- ) -> "Service" :
2477+ ) -> Optional [ "Service" ] :
24782478
24792479 methods = {}
24802480 for k , v in self .methods .items ():
You can’t perform that action at this time.
0 commit comments