This is an automated email from the ASF dual-hosted git repository.
weilee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 66c668e9286 fix mypy errors in airflow-core/src/airflow/jobs/job.py
(#58190)
66c668e9286 is described below
commit 66c668e92861ab2f11eba6ccf248a77a2a9f2eb7
Author: Prafful Javare <[email protected]>
AuthorDate: Thu Nov 13 15:14:36 2025 +0530
fix mypy errors in airflow-core/src/airflow/jobs/job.py (#58190)
---
airflow-core/src/airflow/jobs/job.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/airflow-core/src/airflow/jobs/job.py
b/airflow-core/src/airflow/jobs/job.py
index d6a7cef8a03..660f714698f 100644
--- a/airflow-core/src/airflow/jobs/job.py
+++ b/airflow-core/src/airflow/jobs/job.py
@@ -164,7 +164,7 @@ class Job(Base, LoggingMixin):
@cached_property
def heartrate(self) -> float:
- return Job._heartrate(self.job_type)
+ return Job._heartrate(str(self.job_type))
def is_alive(self) -> bool:
"""
@@ -232,7 +232,7 @@ class Job(Base, LoggingMixin):
self.kill()
# Figure out how long to sleep for
- sleep_for = 0
+ sleep_for: float = 0
if self.latest_heartbeat:
seconds_remaining = (
self.heartrate - (timezone.utcnow() -
self.latest_heartbeat).total_seconds()
@@ -247,7 +247,11 @@ class Job(Base, LoggingMixin):
session.merge(self)
self.latest_heartbeat = timezone.utcnow()
session.commit()
- time_since_last_heartbeat = (timezone.utcnow() -
previous_heartbeat).total_seconds()
+ time_since_last_heartbeat: float = (
+ 0
+ if previous_heartbeat is None
+ else (timezone.utcnow() -
previous_heartbeat).total_seconds()
+ )
health_check_threshold_value =
health_check_threshold(self.job_type, self.heartrate)
if time_since_last_heartbeat >
health_check_threshold_value:
self.log.info("Heartbeat recovered after %.2f
seconds", time_since_last_heartbeat)
@@ -304,7 +308,7 @@ class Job(Base, LoggingMixin):
@provide_session
def most_recent_job(self, session: Session = NEW_SESSION) -> Job | None:
"""Return the most recent job of this type, if any, based on last
heartbeat received."""
- return most_recent_job(self.job_type, session=session)
+ return most_recent_job(str(self.job_type), session=session)
@staticmethod
def _heartrate(job_type: str) -> float: