This is an automated email from the ASF dual-hosted git repository.
amoghdesai 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 eb5318b3e85 Adding a backcompat shim layer for JobState (#54936)
eb5318b3e85 is described below
commit eb5318b3e85b1f940bdb90c96c991beb09910c83
Author: Amogh Desai <[email protected]>
AuthorDate: Tue Aug 26 14:51:22 2025 +0530
Adding a backcompat shim layer for JobState (#54936)
---
airflow-core/src/airflow/utils/__init__.py | 3 ---
airflow-core/src/airflow/utils/state.py | 18 ++++++++++++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/airflow-core/src/airflow/utils/__init__.py
b/airflow-core/src/airflow/utils/__init__.py
index d2bbbf7bf4c..84e999a7c83 100644
--- a/airflow-core/src/airflow/utils/__init__.py
+++ b/airflow-core/src/airflow/utils/__init__.py
@@ -55,9 +55,6 @@ __deprecated_classes = {
"DB_SAFE_MAXIMUM": "airflow.sdk.bases.operator.DB_SAFE_MAXIMUM",
"db_safe_priority": "airflow.sdk.bases.operator.db_safe_priority",
},
- __name__: {
- "JobState": "airflow.jobs.job.JobState",
- },
}
add_deprecated_classes(__deprecated_classes, __name__)
diff --git a/airflow-core/src/airflow/utils/state.py
b/airflow-core/src/airflow/utils/state.py
index 84c80f6832e..b392a023525 100644
--- a/airflow-core/src/airflow/utils/state.py
+++ b/airflow-core/src/airflow/utils/state.py
@@ -214,3 +214,21 @@ class State:
A list of states indicating that a task can be adopted or reset by a
scheduler job
if it was queued by another scheduler job that is not running anymore.
"""
+
+
+def __getattr__(name: str):
+ """Provide backward compatibility for moved classes."""
+ if name == "JobState":
+ import warnings
+
+ from airflow.jobs.job import JobState
+
+ warnings.warn(
+ "The `airflow.utils.state.JobState` attribute is deprecated and
will be removed in a future version. "
+ "Please use `airflow.jobs.job.JobState` instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ return JobState
+
+ raise AttributeError(f"module 'airflow.utils.state' has no attribute
'{name}'")