udim commented on a change in pull request #13493:
URL: https://github.com/apache/beam/pull/13493#discussion_r538775475
##########
File path: sdks/python/apache_beam/transforms/util.py
##########
@@ -785,7 +788,6 @@ def expand(self, pcoll):
@experimental()
@typehints.with_input_types(Tuple[K, V])
- @typehints.with_output_types(Tuple[K, Iterable[V]])
Review comment:
Right, Python's `typing` types don't recognize Beam's own internal
types.
1. Probably not a solution:
ShardedKeyTypeConstraint could inherit from
`typing.Generic[typing.TypeVar('K')]`, but that produces 2 more problems.
Neither are hard but add complexity, plus none of the other Beam typehints do
this.
- Accessing the type argument that Generic stores on different versions
of Python. (`__args__` or `__parameters__` I believe)
- Pickling. Python's typing types have had issues with pickling.
2. Probably the right solution but breaks consistency with the other
decorators:
```py
@typehints.with_output_types(typehints.Tuple[ShardedKeyType[K],
typehints.Iterable[V]])
```
Beam already converts to internal type so this is a cosmetic change.
----------------------------------------------------------------
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:
[email protected]