diff --git a/docs/changelog/next_release/+.bugfix.3.rst b/docs/changelog/next_release/+.bugfix.3.rst new file mode 100644 index 00000000..f8f555e6 --- /dev/null +++ b/docs/changelog/next_release/+.bugfix.3.rst @@ -0,0 +1 @@ +Use ``AttributeError`` instead of ``ImportError`` in module's ``__getattr__`` method, to make code compliant with Python spec. diff --git a/onetl/connection/__init__.py b/onetl/connection/__init__.py index 608beb41..03402fd0 100644 --- a/onetl/connection/__init__.py +++ b/onetl/connection/__init__.py @@ -76,4 +76,4 @@ def __getattr__(name: str): submodule = file_df_connections_modules[name] return getattr(import_module(f"onetl.connection.file_df_connection.{submodule}"), name) - raise ImportError(f"cannot import name {name!r} from {__name__!r}") + raise AttributeError(name) diff --git a/onetl/core/__init__.py b/onetl/core/__init__.py index 9796b173..abbfd0e3 100644 --- a/onetl/core/__init__.py +++ b/onetl/core/__init__.py @@ -40,4 +40,4 @@ def __getattr__(name: str): ) return getattr(import_module(f"onetl.{submodule}"), name) - raise ImportError(f"cannot import name {name!r} from {__name__!r}") + raise AttributeError(name) diff --git a/onetl/hwm/store/__init__.py b/onetl/hwm/store/__init__.py index 4fb2d991..929b1d40 100644 --- a/onetl/hwm/store/__init__.py +++ b/onetl/hwm/store/__init__.py @@ -45,4 +45,4 @@ def __getattr__(name: str): return getattr(import_module("etl_entities.hwm_store"), name) - raise ImportError(f"cannot import name {name!r} from {__name__!r}") + raise AttributeError(name) diff --git a/onetl/strategy/hwm_store/__init__.py b/onetl/strategy/hwm_store/__init__.py index de994c20..2f89a595 100644 --- a/onetl/strategy/hwm_store/__init__.py +++ b/onetl/strategy/hwm_store/__init__.py @@ -39,7 +39,7 @@ def __getattr__(name: str): if name not in __all__: - raise ImportError(f"cannot import name {name!r} from {__name__!r}") + raise AttributeError(name) message = f""" Imports from module {__name__!r} are deprecated since v0.6.0 and will be removed in v1.0.0.