Skip to content

Commit

Permalink
chore: fix bug on raising not impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ncclementi committed Aug 30, 2024
1 parent 4c4fc40 commit 81010a6
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ibis/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ def _execute_if_exists(
self, method_name: str, database=None, like=None
) -> list[str]:
"""Executes method if it exists and it doesn't raise a NotImplementedError, else returns an empty list."""
method = getattr(self._backend.ddl, method_name)
if callable(method):
try:
return method(database=database, like=like)
except NotImplementedError:
pass
try:
method = getattr(self._backend.ddl, method_name)
return method(database=database, like=like)
except NotImplementedError:
pass
return []

def _gather_tables(self, database=None, like=None) -> list[str]:
Expand Down Expand Up @@ -129,11 +128,13 @@ def __init__(self, backend: BaseBackend) -> None:
self._backend = backend

def _raise_if_not_implemented(self, method_name: str):
method = getattr(self._backend, method_name)
if not callable(method):
raise NotImplementedError(
f"The method {method_name} is not implemented for the {self._backend.name} backend"
)
try:
getattr(self._backend, method_name)
except AttributeError as e:
if f"has no attribute '{method_name}'" in str(e):
raise NotImplementedError(
f"The method {method_name} is not implemented for the {self._backend.name} backend"
)

def list_tables(
self, like: str | None = None, database: tuple[str, str] | str | None = None
Expand Down

0 comments on commit 81010a6

Please sign in to comment.