From c67036b66d5abcf6dc26d8fb531b407ad156b957 Mon Sep 17 00:00:00 2001 From: Aleksandrs Drozdovs Date: Sun, 2 Aug 2026 17:24:31 +0100 Subject: [PATCH] fix(typing): read_json's stub only allowed a single path, not a list read_json accepts a list of paths at runtime (e.g. reading several newline-delimited JSON files as one relation), but the type stub only listed a single str/bytes/PathLike/IO. mypy and pyright both reject valid calls like con.read_json(["a.jsonl", "b.jsonl"]) as a result. Widened path_or_buffer to also accept a Sequence of the same union, matching the exact pattern already used by from_parquet/read_parquet and from_csv_auto in this same file. Applied to both the DuckDBPyConnection.read_json method and the module-level read_json wrapper, since both stubs currently disagree with the runtime. Verified with a copy of the repro from the issue: both mypy --strict and pyright report zero errors against the corrected stub, versus the reported error against the original. Fixes #576 --- _duckdb-stubs/__init__.pyi | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/_duckdb-stubs/__init__.pyi b/_duckdb-stubs/__init__.pyi index 8770483f..51daee08 100644 --- a/_duckdb-stubs/__init__.pyi +++ b/_duckdb-stubs/__init__.pyi @@ -404,7 +404,14 @@ class DuckDBPyConnection: ) -> DuckDBPyRelation: ... def read_json( self, - path_or_buffer: str | bytes | os.PathLike[str] | os.PathLike[bytes] | typing.IO[bytes] | typing.IO[str], + # stubgen override: read_json accepts a list of paths at runtime, not just a single one (#576) + path_or_buffer: str + | bytes + | os.PathLike[str] + | os.PathLike[bytes] + | typing.IO[bytes] + | typing.IO[str] + | Sequence[str | bytes | os.PathLike[str] | os.PathLike[bytes] | typing.IO[bytes] | typing.IO[str]], *, columns: ColumnsTypes | None = None, sample_size: int | None = None, @@ -1191,7 +1198,14 @@ def read_csv( strict_mode: bool | None = None, ) -> DuckDBPyRelation: ... def read_json( - path_or_buffer: str | bytes | os.PathLike[str] | os.PathLike[bytes] | typing.IO[bytes] | typing.IO[str], + # stubgen override: read_json accepts a list of paths at runtime, not just a single one (#576) + path_or_buffer: str + | bytes + | os.PathLike[str] + | os.PathLike[bytes] + | typing.IO[bytes] + | typing.IO[str] + | Sequence[str | bytes | os.PathLike[str] | os.PathLike[bytes] | typing.IO[bytes] | typing.IO[str]], *, columns: ColumnsTypes | None = None, sample_size: int | None = None,