potiuk commented on a change in pull request #20425:
URL: https://github.com/apache/airflow/pull/20425#discussion_r773479894
##########
File path: airflow/decorators/task_group.py
##########
@@ -21,28 +21,60 @@
"""
import functools
from inspect import signature
-from typing import Callable, Optional, TypeVar, cast
+from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, TypeVar,
overload
from airflow.utils.task_group import TaskGroup
-T = TypeVar("T", bound=Callable)
+if TYPE_CHECKING:
+ from airflow.models import DAG
+
+F = TypeVar("F", bound=Callable[..., Any])
task_group_sig = signature(TaskGroup.__init__)
-def task_group(python_callable: Optional[Callable] = None, *tg_args,
**tg_kwargs) -> Callable[[T], T]:
+# This covers the @task_group() case. Annotations are copied from the TaskGroup
Review comment:
Nice. I was sure I saw the recipe somewhere :)
https://mypy.readthedocs.io/en/stable/generics.html#declaring-decorators
Thanks!. The Type Hiting of Python is an interesting one.
--
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]