Skip to content

Commit d36ef7e

Browse files
jedcunninghamromsharon98
authored andcommitted
Remove deprecated ImportError from airflow.models (apache#41367)
1 parent 8adc187 commit d36ef7e

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

airflow/models/__init__.py

+5-20
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,13 @@ def import_all_models():
6969

7070
def __getattr__(name):
7171
# PEP-562: Lazy loaded attributes on python modules
72-
if name != "ImportError":
73-
path = __lazy_imports.get(name)
74-
if not path:
75-
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
72+
path = __lazy_imports.get(name)
73+
if not path:
74+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
7675

77-
from airflow.utils.module_loading import import_string
76+
from airflow.utils.module_loading import import_string
7877

79-
val = import_string(f"{path}.{name}")
80-
else:
81-
import warnings
82-
83-
from airflow.exceptions import RemovedInAirflow3Warning
84-
from airflow.models.errors import ParseImportError
85-
86-
warnings.warn(
87-
f"Import '{__name__}.ImportError' is deprecated due to shadowing with builtin exception "
88-
f"ImportError and will be removed in the future. "
89-
f"Please consider to use '{ParseImportError.__module__}.ParseImportError' instead.",
90-
RemovedInAirflow3Warning,
91-
stacklevel=2,
92-
)
93-
val = ParseImportError
78+
val = import_string(f"{path}.{name}")
9479

9580
# Store for next time
9681
globals()[name] = val

newsfragments/41367.significant.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Deprecated ``ImportError`` removed from ``airflow.models``
2+
3+
The deprecated ``ImportError`` class can no longer be imported from ``airflow.models``.
4+
It has been moved to ``airflow.models.errors.ParseImportError``.

0 commit comments

Comments
 (0)