raushanprabhakar1 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3253241961
##########
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##########
@@ -571,35 +599,62 @@ def _create_arg_for_non_primitive_type(
commands = []
if parameter_type_map not in self.datamodels_extended_map.keys():
self.datamodels_extended_map[parameter_type] = []
- for field, field_type in parameter_type_map.model_fields.items():
+ for field, field_info in parameter_type_map.model_fields.items():
if field in self.excluded_parameters:
continue
self.datamodels_extended_map[parameter_type].append(field)
- if type(field_type.annotation) is type:
+ leaf_ann = self._leaf_annotation(field_info.annotation)
+ pydantic_default = None if field_info.default is PydanticUndefined
else field_info.default
+
+ if parameter_type == "ClearTaskInstancesBody" and field ==
"task_ids":
commands.append(
self._create_arg(
arg_flags=("--" +
self._sanitize_arg_parameter_key(field),),
-
arg_type=self._python_type_from_string(field_type.annotation),
- arg_action=argparse.BooleanOptionalAction if
field_type.annotation is bool else None, # type: ignore
+ arg_type=string_list_type,
+ arg_action=None,
arg_help=f"{field} for {parameter_key} operation",
- arg_default=False if field_type.annotation is bool
else None,
+ arg_default=pydantic_default,
)
)
- else:
- try:
- annotation = field_type.annotation.__args__[0]
- except AttributeError:
- annotation = field_type.annotation
+ continue
+ if leaf_ann is bool:
+ cli_bool_default = pydantic_default
+ if parameter_type == "ClearTaskInstancesBody" and field ==
"dry_run":
+ cli_bool_default = False
commands.append(
self._create_arg(
arg_flags=("--" +
self._sanitize_arg_parameter_key(field),),
- arg_type=self._python_type_from_string(annotation),
- arg_action=argparse.BooleanOptionalAction if
annotation is bool else None, # type: ignore
+ arg_type=bool,
+ arg_action=argparse.BooleanOptionalAction,
arg_help=f"{field} for {parameter_key} operation",
- arg_default=False if annotation is bool else None,
+ arg_default=cli_bool_default,
)
)
+ continue
+
+ origin = get_origin(leaf_ann)
+ if leaf_ann is list or origin is list:
Review Comment:
Hi @bugraoz93 , Reverting the global CommandFactory changes.
--
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]