File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
sdks/python/apache_beam/transforms Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -805,15 +805,17 @@ def expand(self, pvalueish: pvalue.PCollection) -> pvalue.PCollection:
805805 urn = common_urns .primitives .IMPULSE .urn ),
806806 outputs = {'out' : transform_proto .inputs [tag ]}))
807807 output_coders = None
808- if self ._type_hints .output_types :
809- if self ._type_hints .output_types [0 ]:
810- output_coders = dict (
811- (str (k ), context .coder_id_from_element_type (v ))
812- for (k , v ) in enumerate (self ._type_hints .output_types [0 ]))
813- elif self ._type_hints .output_types [1 ]:
808+ # Retrieve type hints and store them in variables to avoid duplicate calls and AttributeError
809+ hints = self .get_type_hints ()
810+ output_coders = None
811+ if hints .output_types :
812+ if hints .output_types [0 ]:
813+ output_coders = dict ((str (k ), context .coder_id_from_element_type (v ))
814+ for (k , v ) in enumerate (hints .output_types [0 ]))
815+ elif hints .output_types [1 ]:
814816 output_coders = {
815817 k : context .coder_id_from_element_type (v )
816- for (k , v ) in self . _type_hints .output_types [1 ].items ()
818+ for (k , v ) in hints .output_types [1 ].items ()
817819 }
818820 components = context .to_runner_api ()
819821 request = beam_expansion_api_pb2 .ExpansionRequest (
You can’t perform that action at this time.
0 commit comments