Skip to content

feat(python): type stubs, data= parameter, and cleanup#179

Draft
cpsievert wants to merge 4 commits intofeat/python-exceptions-protocolfrom
feat/python-binding-improvements
Draft

feat(python): type stubs, data= parameter, and cleanup#179
cpsievert wants to merge 4 commits intofeat/python-exceptions-protocolfrom
feat/python-binding-improvements

Conversation

@cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Mar 9, 2026

Depends on #178 (merge that first)

Summary

  • Add type stubs (.pyi) for the native _ggsql extension module, enabling IDE autocompletion and type checking
  • Add data= dict parameter on execute() for registering temporary DataFrames that are automatically cleaned up after execution (even on error)
  • Improve type stub specificity and data cleanup safety

Rust changes

  • data: Option<&Bound<'_, PyDict>> parameter on PyDuckDBReader.execute() and free execute()
  • register_data_dict() / register_data_on_reader() helpers with table_exists() probe to avoid unregistering pre-existing tables
  • Removed try_native_readers! macro (incompatible with cleanup-before-return pattern)

@cpsievert cpsievert marked this pull request as draft March 9, 2026 21:46
cpsievert and others added 4 commits March 9, 2026 16:52
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…taFrames

Allows passing a dict of DataFrames to reader.execute() and the module-level
execute() function, which are registered before query execution and unregistered
afterward (cleanup happens even on error).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…specificity

- Update type stubs to document typed exceptions (ParseError, ReaderError,
  etc.) instead of generic ValueError
- Guard data= cleanup against destroying pre-existing tables by checking
  table existence before registration
- Pass replace as keyword arg in bridge register_data_on_reader for
  compatibility with custom readers that omit the parameter
- Tighten test assertions to expect specific exception types
- Remove unused try_native_readers! macro

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cpsievert cpsievert force-pushed the feat/python-binding-improvements branch from 5a4a2df to b3ec22b Compare March 9, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant