Skip to content

Add connection keyword to read_json and write_csv stubs - #643

Closed
tojacob03 wants to merge 1 commit into
duckdb:v2.0-cyanopterafrom
tojacob03:fix/stubs-connection-read-json-write-csv
Closed

tojacob03 wants to merge 1 commit into
duckdb:v2.0-cyanopterafrom
tojacob03:fix/stubs-connection-read-json-write-csv

Conversation

@tojacob03

Copy link
Copy Markdown

Fixes #627

The module-level duckdb.read_json() and duckdb.write_csv() accept a keyword-only connection argument at runtime (both registrations in src/duckdb_python.cpp end with nb::arg("connection").none() = nb::none()), but _duckdb-stubs/__init__.pyi doesn't declare it. This PR adds it to both stubs in the same form read_parquet already uses.

I also compared every m.def(...) in src/duckdb_python.cpp that takes connection against the module-level stubs. These two are the only functions where it was missing.

Testing

I type-checked the reproduction script from the issue against the duckdb 1.5.6 wheel, swapping in the stubs:

stubs pyright mypy
main 2 errors (No parameter named "connection") 2 errors
this PR 0 errors no issues

At runtime the script runs fine either way.

The module-level duckdb.read_json() and duckdb.write_csv() accept a
keyword-only `connection` argument at runtime (see their registrations
in src/duckdb_python.cpp), but the stubs did not declare it, so type
checkers rejected valid calls.

Fixes duckdb#627

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tojacob03
tojacob03 changed the base branch from main to v2.0-cyanoptera September 29, 2026 15:43
@evertlammerts

Copy link
Copy Markdown
Member

Thank you for the careful PR and the table of checker results, and sorry for the silence. Since you opened it, the 2.0 line moved the module level read_json and write_csv into Python, and those functions declare connection= themselves, so the stubs you edited no longer exist. I checked your repro against 2.0.0 and mypy reports no errors. I am closing this as superseded. Thanks again for tracking down the gap.

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.

Type stubs omit the connection keyword on module-level read_json and write_csv

2 participants