@@ -55,6 +55,22 @@ class _PlannedMethod(NamedTuple):
5555 in_service : bool
5656 in_service_impl : bool
5757
58+ @classmethod
59+ def build (
60+ cls ,
61+ spec : MethodSpec ,
62+ own_virtual_decls : set [str ],
63+ service_impl_callable : set [str ],
64+ ) -> "_PlannedMethod" :
65+ in_service = spec .emit_service
66+ return cls (
67+ spec = spec ,
68+ in_ifc = spec .decl in own_virtual_decls ,
69+ in_api = spec .emit_api and spec .source_virtual ,
70+ in_service = in_service ,
71+ in_service_impl = in_service and spec .call_name in service_impl_callable ,
72+ )
73+
5874
5975class ServiceModelBuilder :
6076 class _ResolvedServiceOptions (NamedTuple ):
@@ -156,11 +172,10 @@ def _build(self) -> ServiceModel:
156172 if (options .generate_service_impl and options .generate_api )
157173 else service_callable
158174 )
159- methods = self ._build_planned_methods (
160- lineage_specs ,
161- own_virtual_decls ,
162- service_impl_callable ,
163- )
175+ methods = [
176+ _PlannedMethod .build (spec , own_virtual_decls , service_impl_callable )
177+ for spec in lineage_specs
178+ ]
164179
165180 include_list = self ._uniq (self ._collect_lineage_includes (lineage ))
166181
@@ -366,24 +381,3 @@ def _snake_case(name: str) -> str:
366381 @staticmethod
367382 def _uniq (values : List [str ]) -> List [str ]:
368383 return list (dict .fromkeys (values ))
369-
370- @staticmethod
371- def _build_planned_methods (
372- lineage_method_specs ,
373- own_virtual_decls ,
374- service_impl_callable ,
375- ) -> List [_PlannedMethod ]:
376- methods : List [_PlannedMethod ] = []
377- for spec in lineage_method_specs :
378- in_service = spec .emit_service
379- methods .append (
380- _PlannedMethod (
381- spec = spec ,
382- in_ifc = spec .decl in own_virtual_decls ,
383- in_api = spec .emit_api and spec .source_virtual ,
384- in_service = in_service ,
385- in_service_impl = in_service
386- and spec .call_name in service_impl_callable ,
387- )
388- )
389- return methods
0 commit comments