udim commented on a change in pull request #12009: URL: https://github.com/apache/beam/pull/12009#discussion_r445941065
########## File path: sdks/python/apache_beam/typehints/decorators.py ########## @@ -378,6 +379,61 @@ def has_simple_output_type(self): self.output_types and len(self.output_types[0]) == 1 and not self.output_types[1]) + def strip_pcoll_input(self): + # type: () -> IOTypeHints + + error_str = 'An input typehint to a PTransform must be a single (or nested) type wrapped by a PCollection or ' \ + 'PBegin. ' + + if any(element is None for element in [self.input_types, self.input_types[0], self.input_types[0][0]]): Review comment: This line will raise an exception when self.input_types is None, compared to: ```py if self.input_types is None or len(self.input_types[0]) != 1: ``` It doesn't take advantage of short-circuit evaluation. `self.input_types = None` is a valid value. It means nothing was set. (We should get rid of that and always have ((), {}) as the input/output_types value if there are no type hints, but I haven't had the chance to do that.) Same goes for having zero type hints: it's valid and there's nothing to do. Might be useful to reuse: `self._has_input_types`, `self.has_simple_output_type`. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org