From 6e833580335e5452855923310b3301ab8a2fd2da Mon Sep 17 00:00:00 2001 From: dirrao Date: Mon, 19 Aug 2024 13:57:20 +0530 Subject: [PATCH 1/2] decorators deprecated apply_defaults removal --- airflow/sensors/base.py | 5 ----- airflow/utils/decorators.py | 34 +--------------------------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/airflow/sensors/base.py b/airflow/sensors/base.py index 7df76fae52883..8efcc5da4179b 100644 --- a/airflow/sensors/base.py +++ b/airflow/sensors/base.py @@ -45,11 +45,6 @@ from airflow.models.taskreschedule import TaskReschedule from airflow.ti_deps.deps.ready_to_reschedule import ReadyToRescheduleDep from airflow.utils import timezone - -# We need to keep the import here because GCSToLocalFilesystemOperator released in -# Google Provider before 3.0.0 imported apply_defaults from here. -# See https://github.com/apache/airflow/issues/16035 -from airflow.utils.decorators import apply_defaults # noqa: F401 from airflow.utils.session import NEW_SESSION, provide_session if TYPE_CHECKING: diff --git a/airflow/utils/decorators.py b/airflow/utils/decorators.py index 77a5eddaf0888..4cad5ab9e6073 100644 --- a/airflow/utils/decorators.py +++ b/airflow/utils/decorators.py @@ -18,44 +18,12 @@ from __future__ import annotations import sys -import warnings from collections import deque -from functools import wraps -from typing import Callable, TypeVar, cast - -from airflow.exceptions import RemovedInAirflow3Warning +from typing import Callable, TypeVar T = TypeVar("T", bound=Callable) -def apply_defaults(func: T) -> T: - """ - Use apply_default decorator for the `default_args` feature to work properly; deprecated. - - In previous versions, all subclasses of BaseOperator must use apply_default decorator for the" - `default_args` feature to work properly. - - In current version, it is optional. The decorator is applied automatically using the metaclass. - """ - warnings.warn( - "This decorator is deprecated. \n" - "\n" - "In previous versions, all subclasses of BaseOperator must use apply_default decorator for the " - "`default_args` feature to work properly.\n" - "\n" - "In current version, it is optional. The decorator is applied automatically using the metaclass.\n", - RemovedInAirflow3Warning, - stacklevel=3, - ) - - # Make it still be a wrapper to keep the previous behaviour of an extra stack frame - @wraps(func) - def wrapper(*args, **kwargs): - return func(*args, **kwargs) - - return cast(T, wrapper) - - def remove_task_decorator(python_source: str, task_decorator_name: str) -> str: """ Remove @task or similar decorators as well as @setup and @teardown. From f4fc39c0c6e92a24747a59ec0f0111cec596e380 Mon Sep 17 00:00:00 2001 From: dirrao Date: Mon, 19 Aug 2024 14:03:00 +0530 Subject: [PATCH 2/2] news fragment added --- newsfragments/41579.significant.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/41579.significant.rst diff --git a/newsfragments/41579.significant.rst b/newsfragments/41579.significant.rst new file mode 100644 index 0000000000000..1aae04e2be13e --- /dev/null +++ b/newsfragments/41579.significant.rst @@ -0,0 +1 @@ +Removed deprecated ``apply_defaults`` function from ``airflow/utils/decorators.py``.