diff --git a/ibis/backends/base/__init__.py b/ibis/backends/base/__init__.py index 7c98b3269334..3e9517a485a6 100644 --- a/ibis/backends/base/__init__.py +++ b/ibis/backends/base/__init__.py @@ -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() diff --git a/ibis/backends/tests/test_api.py b/ibis/backends/tests/test_api.py index 8db8031fd919..996007a03d7c 100644 --- a/ibis/backends/tests/test_api.py +++ b/ibis/backends/tests/test_api.py @@ -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", [