amoghrajesh commented on code in PR #55488:
URL: https://github.com/apache/airflow/pull/55488#discussion_r2338127546
##########
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##########
@@ -468,12 +468,13 @@ def _python_type_from_string(type_name: str | type) ->
type | Callable:
"tuple": tuple,
"set": set,
"datetime.datetime": parsedate,
+ "dict[str, typing.Any]": dict,
Review Comment:
Instead of this, I think we could just handle it using: get_origin():
https://docs.python.org/3/library/typing.html#typing.get_origin
Maybe like:
```
--- a/airflow-ctl/src/airflowctl/ctl/cli_config.py
+++ b/airflow-ctl/src/airflowctl/ctl/cli_config.py
@@ -447,6 +447,7 @@ class CommandFactory:
@staticmethod
def _python_type_from_string(type_name: str | type) -> type | Callable:
"""
Return the corresponding Python *type* for a primitive type name
string.
@@ -470,6 +471,12 @@ class CommandFactory:
}
# Default to ``str`` to preserve previous behaviour for any
unrecognised
# type names while still allowing the CLI to function.
+ try:
+ import typing
+ origin = typing.get_origin(type_name)
+ if origin is not None and origin in mapping:
+ return mapping[origin]
+ except (ImportError, AttributeError):
+ pass
if isinstance(type_name, type):
type_name = type_name.__name__
return mapping.get(type_name, str)
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]