Skip to content

Commit

Permalink
Remove deprecated param in DayOfWeekSensor (#41393)
Browse files Browse the repository at this point in the history
The `use_task_execution_day` param is deprecated
  • Loading branch information
kaxil authored Aug 12, 2024
1 parent b809ee1 commit aa047d7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
11 changes: 0 additions & 11 deletions airflow/sensors/weekday.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
# under the License.
from __future__ import annotations

import warnings
from typing import TYPE_CHECKING, Iterable

from airflow.exceptions import RemovedInAirflow3Warning
from airflow.sensors.base import BaseSensorOperator
from airflow.utils import timezone
from airflow.utils.weekday import WeekDay
Expand Down Expand Up @@ -75,7 +73,6 @@ class DayOfWeekSensor(BaseSensorOperator):
with week_day. Execution Date is Useful for backfilling.
If ``False``, uses system's day of the week. Useful when you
don't want to run anything on weekdays on the system.
:param use_task_execution_day: deprecated parameter, same effect as `use_task_logical_date`
.. seealso::
For more information on how to use this sensor, take a look at the guide:
Expand All @@ -88,19 +85,11 @@ def __init__(
*,
week_day: str | Iterable[str] | WeekDay | Iterable[WeekDay],
use_task_logical_date: bool = False,
use_task_execution_day: bool = False,
**kwargs,
) -> None:
super().__init__(**kwargs)
self.week_day = week_day
self.use_task_logical_date = use_task_logical_date
if use_task_execution_day:
self.use_task_logical_date = use_task_execution_day
warnings.warn(
"Parameter ``use_task_execution_day`` is deprecated. Use ``use_task_logical_date``.",
RemovedInAirflow3Warning,
stacklevel=2,
)
self._week_day_num = WeekDay.validate_week_day(week_day)

def poke(self, context: Context) -> bool:
Expand Down
18 changes: 18 additions & 0 deletions newsfragments/newsfragments/41393.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
**Breaking Change**

The ``use_task_execution_day`` parameter has been removed from the ``DayOfWeekSensor`` class.
This parameter was previously deprecated in favor of ``use_task_logical_date``.

If your code still uses ``use_task_execution_day``, you should update it to use ``use_task_logical_date``
instead to ensure compatibility with future Airflow versions.

Example update:

.. code-block:: python
sensor = DayOfWeekSensor(
task_id="example",
week_day="Tuesday",
use_task_logical_date=True,
dag=dag,
)
15 changes: 0 additions & 15 deletions tests/sensors/test_weekday_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,3 @@ def test_weekday_sensor_timeout_with_set(self):
)
with pytest.raises(AirflowSensorTimeout):
op.run(start_date=WEEKDAY_DATE, end_date=WEEKDAY_DATE, ignore_ti_state=True)

def test_deprecation_warning(self):
warning_message = (
"""Parameter ``use_task_execution_day`` is deprecated. Use ``use_task_logical_date``."""
)
with pytest.warns(DeprecationWarning) as warnings:
DayOfWeekSensor(
task_id="week_day_warn",
poke_interval=1,
timeout=2,
week_day="Tuesday",
use_task_execution_day=True,
dag=self.dag,
)
assert warning_message == str(warnings[0].message)

0 comments on commit aa047d7

Please sign in to comment.