-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[Feature Request]: Support TypedDict hint in Apache Beam. #24704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Update the issue title? |
Done, thanks. |
Why have specific code for
|
The value of TypedDict over Mapping is if the different keys are expected to have different values. For example, let's say I did the following:
If using Mapping, the method would have to start:
since the type checker can't tell which key corresponds with which value type. If I could instead have a TypedDict, it could be a bit cleaner:
and the type checker needs no additional help. |
cc: @jrmccluskey |
Uh oh!
There was an error while loading. Please reload this page.
What would you like to happen?
CoGroupByKey produces Dict[K, Union[...]], which is narrower than TypedDict. If the user follows the CoGroupByKey with a ParDo where the function takes TypeDict as input, e.g.
ParDo(fn(element: TypedDict))
, then the type check in Beam fails.Users having types like:
are using less specific hints like
myLessSpecificDict = Dict(str, Union[List[Field1Type], List[Field2Type]])
in order to satisfy beams typing.We could have a first-class typehint TypeDict, which may be easier once we deprecate Python 3.7.
Issue Priority
Priority: 3 (nice-to-have improvement)
Issue Components
The text was updated successfully, but these errors were encountered: