From c7b6a7234944dae4527dc5e81441b732a8257712 Mon Sep 17 00:00:00 2001 From: Jed Cunningham Date: Fri, 9 Aug 2024 15:03:48 -0600 Subject: [PATCH] Remove deprecated ``ImportError`` from ``airflow.models`` --- airflow/models/__init__.py | 25 +++++-------------------- newsfragments/41367.significant.rst | 4 ++++ 2 files changed, 9 insertions(+), 20 deletions(-) create mode 100644 newsfragments/41367.significant.rst diff --git a/airflow/models/__init__.py b/airflow/models/__init__.py index bbf9c13567eb3..9754df4156e27 100644 --- a/airflow/models/__init__.py +++ b/airflow/models/__init__.py @@ -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 diff --git a/newsfragments/41367.significant.rst b/newsfragments/41367.significant.rst new file mode 100644 index 0000000000000..410d5941bfab7 --- /dev/null +++ b/newsfragments/41367.significant.rst @@ -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``.