Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 5 additions & 20 deletions airflow/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,13 @@ def import_all_models():

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

from airflow.utils.module_loading import import_string
from airflow.utils.module_loading import import_string

val = import_string(f"{path}.{name}")
else:
import warnings

from airflow.exceptions import RemovedInAirflow3Warning
from airflow.models.errors import ParseImportError

warnings.warn(
f"Import '{__name__}.ImportError' is deprecated due to shadowing with builtin exception "
f"ImportError and will be removed in the future. "
f"Please consider to use '{ParseImportError.__module__}.ParseImportError' instead.",
RemovedInAirflow3Warning,
stacklevel=2,
)
val = ParseImportError
val = import_string(f"{path}.{name}")

# Store for next time
globals()[name] = val
Expand Down
4 changes: 4 additions & 0 deletions newsfragments/41367.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Deprecated ``ImportError`` removed from ``airflow.models``

The deprecated ``ImportError`` class can no longer be imported from ``airflow.models``.
It has been moved to ``airflow.models.errors.ParseImportError``.