bugraoz93 commented on PR #50132: URL: https://github.com/apache/airflow/pull/50132#issuecomment-3083399561
> @bugraoz93 , Should this generic-method need to return pydantic_model instead of list ? > > ```def list(self) -> list | ServerResponseError: > """List all pools.""" > return super().execute_list(path="pools", data_model=PoolCollectionResponse) > ``` > shows > > ``` > root@9d080af5f645:/opt/airflow# airflowctl pools list > Please enter password for encrypted keyring: > Traceback (most recent call last): > File "/usr/local/bin/airflowctl", line 10, in <module> > sys.exit(main()) > File "/opt/airflow/airflow-ctl/src/airflowctl/__main__.py", line 34, in main > safe_call_command(args.func, args=args) > File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 66, in safe_call_command > function(args) > File "/opt/airflow/airflow-ctl/src/airflowctl/api/client.py", line 329, in wrapper > return func(*args, api_client=api_client, **kwargs) > File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 596, in _get_func > data=check_operation_and_collect_list_of_dict(convert_to_dict(method_output)), > File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 584, in check_operation_and_collect_list_of_dict > if is_dict_nested(dict_obj): > File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 581, in is_dict_nested > return any(isinstance(i, dict) or isinstance(i, list) for i in obj.values()) > AttributeError: 'list' object has no attribute 'values > ``` > > breaking here : > ``` > def is_dict_nested(obj: dict) -> bool: > """Check if the object is a nested dictionary.""" > return any(isinstance(i, dict) or isinstance(i, list) for i in obj.values()) > ``` As this merged yesterday to prettify the output. If you extend the Pydantic model list and return with Model(list, total_entries) it should work out of the box If you think it will be hard, you can add it there if it is a sequence of dict means, a list of dict, you can directly return the response without hitting any of those things because AirflowConsole.print_as accepts a list of dict or any type of sequence dict :) If you experience problems, please let me know I can check later today and find a way to adopt it -- 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]
