Skip to content

Commit

Permalink
Python: Add __repr__ for Catalog (#8558)
Browse files Browse the repository at this point in the history
* Python: Add `__repr__` for `Table` and `Catalog`

* remove properties in `__repr__` output

* remove table `__repr__`

* clean up catalog __repr__ and add test

* actually use repr instead of str

* Update python/tests/catalog/test_base.py

Co-authored-by: Fokko Driesprong <[email protected]>

* Update python/pyiceberg/catalog/__init__.py

* Update python/tests/catalog/test_base.py

---------

Co-authored-by: Fokko Driesprong <[email protected]>
  • Loading branch information
jayceslesar and Fokko authored Sep 22, 2023
1 parent 9aeea63 commit f2ce4ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/pyiceberg/catalog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,7 @@ def _get_updated_props_and_update_summary(
)

return properties_update_summary, updated_properties

def __repr__(self) -> str:
"""Return the string representation of the Catalog class."""
return f"{self.name} ({self.__class__})"
5 changes: 5 additions & 0 deletions python/tests/catalog/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,8 @@ def test_add_column_with_statement(catalog: InMemoryCatalog) -> None:
schema_id=0,
identifier_field_ids=[],
)


def test_catalog_repr(catalog: InMemoryCatalog) -> None:
s = repr(catalog)
assert s == "test.in.memory.catalog (<class 'test_base.InMemoryCatalog'>)"

0 comments on commit f2ce4ef

Please sign in to comment.