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

More typing in TimeSensor and TimeSensorAsync #39696

Merged
merged 2 commits into from
May 20, 2024
Merged
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
8 changes: 4 additions & 4 deletions airflow/sensors/time_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class TimeSensor(BaseSensorOperator):

"""

def __init__(self, *, target_time, **kwargs):
def __init__(self, *, target_time: datetime.time, **kwargs) -> None:
super().__init__(**kwargs)
self.target_time = target_time

def poke(self, context: Context):
def poke(self, context: Context) -> bool:
self.log.info("Checking if the time (%s) has come", self.target_time)
return timezone.make_naive(timezone.utcnow(), self.dag.timezone).time() > self.target_time

Expand All @@ -62,7 +62,7 @@ class TimeSensorAsync(BaseSensorOperator):
:ref:`howto/operator:TimeSensorAsync`
"""

def __init__(self, *, target_time, **kwargs):
def __init__(self, *, target_time: datetime.time, **kwargs) -> None:
super().__init__(**kwargs)
self.target_time = target_time

Expand All @@ -79,6 +79,6 @@ def execute(self, context: Context):
method_name="execute_complete",
)

def execute_complete(self, context, event=None):
def execute_complete(self, context, event=None) -> None:
"""Execute when the trigger fires - returns immediately."""
return None