Bug: StrEnum values in task function arguments get converted to strings, breaking method access #46792
Unanswered
leoperegrino
asked this question in
General
Replies: 2 comments
-
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval. |
Beta Was this translation helpful? Give feedback.
0 replies
-
StrEnum is not supported for Python < 3.11. I doubt we want to add conditional code for Python 3.9 and 3.10 to handle StrEnums and Airflow is 3.9+ currently. I will convert it to a discussion - if more discussion is needed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Apache Airflow version
Other Airflow 2 version (please specify below)
If "Other Airflow 2 version" selected, which one?
apache/airflow:2.8.1-python3.11
What happened?
I'm running
apache/airflow:2.8.1-python3.11
container and working withEnum
andStrEnum
to help me with the type system. The main difference between these two enum types is thatStrEnum
when cast to string (f'{MyStrEnum.A}'
orstr(MyStrEnum.A)
) will auto use the.value
attribute.When passing a
StrEnum
to atasks
decorated function,StrEnum
arguments will be cast to string. Calls toStrEnum
methods then raiseAttributeError
. Normal enums work as usual.What you think should happen instead?
The
StrEnum
argument should maintain its enum type when passed to the task, just like the regularEnum
does. The task function signature indicates that the parameter should be aMyStrEnum
instance, not a string.While
StrEnum
is designed to automatically convert to string during string operations, this auto-conversion should not happen during parameter passing.How to reproduce
Operating System
Amazon Linux 2023
Versions of Apache Airflow Providers
No response
Deployment
Docker-Compose
Deployment details
No response
Anything else?
test_enum
test_str_enum
Are you willing to submit PR?
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions