-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Cannot use TypedDict object when defining params #29358
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
Thanks for opening your first issue here! Be sure to follow the issue template! |
Relevant mypy discussion on passing |
Feel free to work on it. |
@jcobb-healx Are you still working on this ? Don't hesitate to reach out if you need some help :) |
@pierrejeambrun Sorry, I hadn't gotten around to looking at this. Spent a bit of time on this today, and it looks like converting the type hint to |
@pierrejeambrun I've made the changes to use |
Apache Airflow version
2.5.1
What happened
Context: I am attempting to use TypedDict objects to maintain the keys used in DAG params in a single place, and check for key names across multiple DAGs that use the params.
This raises an error with
mypy
asparams
expects anOptional[Dict]
. Due to the invariance ofDict
, this does not acceptTypedDict
objects.What happened: I passed a
TypedDict
to theparams
arg ofDAG
and got a TypeError.What you think should happen instead
TypedDict
objects should be accepted byDAG
, which should acceptOptional[Mapping[str, Any]]
.Unless I'm mistaken,
params
are converted to aParamsDict
class and therefore the appropriate type hint is a genericMapping
type.How to reproduce
Steps to reproduce
Operating System
Amazon Linux
Versions of Apache Airflow Providers
No response
Deployment
Docker-Compose
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: