Skip to content

Commit

Permalink
Remove deprecated ImportError from airflow.models (apache#41367)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedcunningham authored Aug 12, 2024
1 parent 4fd77ec commit b809ee1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
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``.

0 comments on commit b809ee1

Please sign in to comment.