Skip to content

Commit

Permalink
feat: nicer repr for Backend.tables
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCrews authored and jcrist committed Jan 24, 2023
1 parent 702de5d commit 0d319ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ibis/backends/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ def __dir__(self) -> list[str]:
)
return list(o)

def __repr__(self) -> str:
tables = self._backend.list_tables()
rows = ["Tables", "------"]
rows.extend(f"- {name}" for name in sorted(tables))
return "\n".join(rows)

def _ipython_key_completions_(self) -> list[str]:
return self._backend.list_tables()

Expand Down
5 changes: 5 additions & 0 deletions ibis/backends/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ def test_tables_accessor_tab_completion(con):
assert 'functional_alltypes' in keys


def test_tables_accessor_repr(con):
result = repr(con.tables)
assert '- functional_alltypes' in result


@pytest.mark.parametrize(
"expr_fn",
[
Expand Down

0 comments on commit 0d319ca

Please sign in to comment.