ashb commented on code in PR #43076:
URL: https://github.com/apache/airflow/pull/43076#discussion_r1823064821
##########
airflow/models/dag.py:
##########
@@ -332,34 +294,28 @@ def _create_orm_dagrun(
return run
-# TODO: The following mapping is used to validate that the arguments passed to
the DAG are of the correct
-# type. This is a temporary solution until we find a more sophisticated
method for argument validation.
-# One potential method is to use `get_type_hints` from the typing module.
However, this is not fully
-# compatible with future annotations for Python versions below 3.10. Once we
require a minimum Python
-# version that supports `get_type_hints` effectively or find a better
approach, we can replace this
-# manual type-checking method.
-DAG_ARGS_EXPECTED_TYPES = {
- "dag_id": str,
- "description": str,
- "max_active_tasks": int,
- "max_active_runs": int,
- "max_consecutive_failed_dag_runs": int,
- "dagrun_timeout": timedelta,
- "default_view": str,
- "orientation": str,
- "catchup": bool,
- "doc_md": str,
- "is_paused_upon_creation": bool,
- "render_template_as_native_obj": bool,
- "tags": Collection,
- "auto_register": bool,
- "fail_stop": bool,
- "dag_display_name": str,
-}
+if TYPE_CHECKING:
+ dag = task_sdk_dag_decorator
+else:
+
+ def dag(dag_id: str = "", **kwargs):
Review Comment:
The reason I don't want this when type checking is so because the `if
TYPE_CHECKING` version has named args (so that it remains useful for ide
completion) -- so if we removed this here we'd loose helpful IDE
completion/type checking of dag decorator.
--
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]