Skip to content

Commit 5f0fe3c

Browse files
chore(fix-2530): document duck typing pattern in catalog fixtures
Add inline comments to catalog and catalog_with_warehouse fixtures explaining the hasattr(cat, 'close') pattern. This clarifies that: - Not all catalog implementations provide close() (REST, Glue catalogs don't) - SQLCatalog does provide close() for proper connection cleanup - The pattern prevents AttributeError while supporting resource cleanup - This is essential for Python 3.13+ ResourceWarning prevention (issue #2530) This helps future contributors understand why the pattern is necessary and when they should update it if new catalog types are added. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent c8db549 commit 5f0fe3c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,6 +3149,10 @@ def catalog(request: pytest.FixtureRequest, tmp_path: Path) -> Generator[Catalog
31493149
yield cat
31503150
if hasattr(cat, "destroy_tables"):
31513151
cat.destroy_tables()
3152+
# Use duck typing to safely call close() only if available.
3153+
# Not all catalog implementations (e.g., REST, Glue) have close(), but SQLCatalog does.
3154+
# This pattern prevents AttributeError while supporting proper resource cleanup for
3155+
# catalogs that manage connections. See issue #2530 for Python 3.13 ResourceWarning fix.
31523156
if hasattr(cat, "close"):
31533157
cat.close()
31543158

@@ -3163,6 +3167,10 @@ def catalog_with_warehouse(
31633167
yield cat
31643168
if hasattr(cat, "destroy_tables"):
31653169
cat.destroy_tables()
3170+
# Use duck typing to safely call close() only if available.
3171+
# Not all catalog implementations (e.g., REST, Glue) have close(), but SQLCatalog does.
3172+
# This pattern prevents AttributeError while supporting proper resource cleanup for
3173+
# catalogs that manage connections. See issue #2530 for Python 3.13 ResourceWarning fix.
31663174
if hasattr(cat, "close"):
31673175
cat.close()
31683176

0 commit comments

Comments
 (0)