You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type hints for read_json() not updated for file-like input #419
When type checking the program below, which invokes read_json() on a StringIO, e.g. with pyright, errors like the following are produced:
/path/to/foobar.py:8:22 - error: Argument of type "StringIO" cannot be assigned to parameter "path_or_buffer" of type "str | bytes | PathLike[str]" in function "read_json"
Type "StringIO" is not assignable to type "str | bytes | PathLike[str]"
"StringIO" is not assignable to "str"
"StringIO" is not assignable to "bytes"
"StringIO" is incompatible with protocol "PathLike[str]"
"__fspath__" is not present (reportArgumentType)
…
Since duckdb/duckdb#13040 the read_json() methods can also read from file-like objects. Akin to #279, the read_json() stubs in _duckdb-stubs/__init__.pyi also need to have … | typing.IO[bytes] or similar added to the acceptable types for their path_or_buffer parameters.
Activity
Fix stubs for path_or_buffer param (#425)
evertlammerts commentedon Apr 10, 2026
Thanks for the report, I fixed the stubs in #425. v1.5.2 will ship (probably next week) with these and many other stub fixes.