Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated TaskMixin class #41394

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions airflow/models/taskmixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
# under the License.
from __future__ import annotations

import warnings
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING, Any, Iterable, Sequence

from airflow.exceptions import AirflowException, RemovedInAirflow3Warning
from airflow.exceptions import AirflowException
from airflow.utils.types import NOTSET

if TYPE_CHECKING:
Expand Down Expand Up @@ -89,7 +88,7 @@ def update_relative(
self, other: DependencyMixin, upstream: bool = True, edge_modifier: EdgeModifier | None = None
) -> None:
"""
Update relationship information about another TaskMixin. Default is no-op.
Update relationship information about another DependencyMixin. Default is no-op.

Override if necessary.
"""
Expand Down Expand Up @@ -128,22 +127,6 @@ def _iter_references(cls, obj: Any) -> Iterable[tuple[DependencyMixin, str]]:
yield from cls._iter_references(o)


class TaskMixin(DependencyMixin):
"""
Mixin to provide task-related things.

:meta private:
"""

def __init_subclass__(cls) -> None:
warnings.warn(
f"TaskMixin has been renamed to DependencyMixin, please update {cls.__name__}",
category=RemovedInAirflow3Warning,
stacklevel=2,
)
return super().__init_subclass__()


class DAGNode(DependencyMixin, metaclass=ABCMeta):
"""
A base class for a node in the graph of a workflow.
Expand Down
8 changes: 4 additions & 4 deletions airflow/models/xcom_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,20 @@ def apply_upstream_relationship(op: Operator, arg: Any):

@property
def roots(self) -> list[DAGNode]:
"""Required by TaskMixin."""
"""Required by DependencyMixin."""
return [op for op, _ in self.iter_references()]

@property
def leaves(self) -> list[DAGNode]:
"""Required by TaskMixin."""
"""Required by DependencyMixin."""
return [op for op, _ in self.iter_references()]

def set_upstream(
self,
task_or_task_list: DependencyMixin | Sequence[DependencyMixin],
edge_modifier: EdgeModifier | None = None,
):
"""Proxy to underlying operator set_upstream method. Required by TaskMixin."""
"""Proxy to underlying operator set_upstream method. Required by DependencyMixin."""
for operator, _ in self.iter_references():
operator.set_upstream(task_or_task_list, edge_modifier)

Expand All @@ -157,7 +157,7 @@ def set_downstream(
task_or_task_list: DependencyMixin | Sequence[DependencyMixin],
edge_modifier: EdgeModifier | None = None,
):
"""Proxy to underlying operator set_downstream method. Required by TaskMixin."""
"""Proxy to underlying operator set_downstream method. Required by DependencyMixin."""
for operator, _ in self.iter_references():
operator.set_downstream(task_or_task_list, edge_modifier)

Expand Down
4 changes: 2 additions & 2 deletions airflow/utils/task_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,12 @@ def has_task(self, task: BaseOperator) -> bool:

@property
def roots(self) -> list[BaseOperator]:
"""Required by TaskMixin."""
"""Required by DependencyMixin."""
return list(self.get_roots())

@property
def leaves(self) -> list[BaseOperator]:
"""Required by TaskMixin."""
"""Required by DependencyMixin."""
return list(self.get_leaves())

def get_roots(self) -> Generator[BaseOperator, None, None]:
Expand Down
6 changes: 6 additions & 0 deletions newsfragments/41394.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**Breaking Change**

The ``airflow.models.taskMixin.TaskMixin`` class has been removed. It was previously
deprecated in favor of the ``airflow.models.taskMixin.DependencyMixin`` class.
If your code relies on ``TaskMixin``, please update it to use ``DependencyMixin`` instead
to ensure compatibility with Airflow 3.0 and beyond.