Skip to content

Commit

Permalink
[DOP-20674] Replace ImportError with AttributeError in __getattr__
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfinus committed Oct 17, 2024
1 parent a97e63b commit 6b29329
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changelog/next_release/+.bugfix.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use ``AttributeError`` instead of ``ImportError`` in module's ``__getattr__`` method, to make code compliant with Python spec.
2 changes: 1 addition & 1 deletion onetl/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion onetl/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion onetl/hwm/store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion onetl/strategy/hwm_store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6b29329

Please sign in to comment.