Type stubs omit the `connection` keyword on module-level `read_json` and `write_csv`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 90/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- developer-experience, testing-qa
Direzione di ricerca
Inizia in _duckdb-stubs/init.pyi confrontando le firme a livello di modulo di read_json e write_csv con read_parquet, quindi controlla le registrazioni corrispondenti in src/duckdb_python.cpp. Aggiungi la copertura per connection= in tests/fast/test_non_default_conn.py ed esegui questi test insieme a pyright sullo script di riproduzione; il lavoro è completato quando entrambe le chiamate superano il controllo dei tipi e i test passano.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens?
The module-level duckdb.read_json(...) and duckdb.write_csv(...) accept a connection= keyword at runtime, but _duckdb-stubs/__init__.pyi doesn't declare it for either, so every type-checked call that passes connection= is reported as an error (pyright: No parameter named "connection"). The neighbouring read_parquet stub does declare it, and the C++ registration for both functions ends with nb::arg("connection").none() = nb::none() (src/duckdb_python.cpp, the read_json and write_csv definitions), so this is a stub gap rather than a runtime one — the same shape as #386.
To Reproduce
import duckdb, tempfile, os, json
con = duckdb.connect()
d = tempfile.mkdtemp()
p = os.path.join(d, "x.json")
with open(p, "w") as f:
f.write(json.dumps([{"a": 1}, {"a": 2}]))
print(duckdb.read_json(p, connection=con).fetchall()) # runtime OK
duckdb.write_csv(duckdb.values([1]), os.path.join(d, "o.csv"), connection=con) # runtime OK
[(1,), (2,)]
Type-checking the same script:
pyright x.py
error: No parameter named "connection" (reportCallIssue) # read_json
error: No parameter named "connection" (reportCallIssue) # write_csv
A diff of every nb::arg(...) registration in src/**/*.cpp against the stub signatures shows exactly these two functions as gaps. tests/fast/test_non_default_conn.py already asserts connection=duckdb_cursor on ten module functions and covers neither of these.
OS:
macOS 15 (aarch64)
DuckDB Package Version:
1.5.5 (also present on main)
Python Version:
3.13
Full Name:
Joaquin Hui Gomez
Affiliation:
Independent contributor
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a source build
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- Yes, I have
Happy to send the two-line stub fix plus the two test cases in test_non_default_conn.py if that's welcome.
- Lingua principale
- Python
- Stelle
- 186
- Fork
- 113
- Merge medio
- 20h 58m
- PR unite (30g)
- 11
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di duckdb/duckdb-python
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
duckdb/duckdb-python#576 · 3 commenti ·
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
duckdb/duckdb-python#534 ·
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
duckdb/duckdb-python#386 ·
-
needs triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
duckdb/duckdb-python#622 ·
-
needs triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
duckdb/duckdb-python#617 · 2 commenti ·
Tutte le issue di duckdb/duckdb-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100