pyjson5
pyjson5 copied to clipboard
typing error in python 3.13
I'm getting a typing error (with pyright) in python 3.13 with this:
with open(path, 'r', encoding='utf-8') as f:
config_data = json5.load(f)
The error is
config.py:752:27 - error: Type of "load" is partially unknown
Type of "load" is "(fp: IO[Unknown], *, encoding: str | None = None, cls: Any = None, object_hook: ((Mapping[str, Any]) -> Any) | None = None, parse_float: ((str) -> Any) | None = None, parse_int: ((str) -> Any) | None = None, parse_constant: ((str) -> Any) | None = None, strict: bool = True, object_pairs_hook: ((Iterable[Tuple[str, Any]]) -> Any) | None = None, allow_duplicate_keys: bool = True, consume_trailing: bool = True, start: int | None = None) -> Any" (reportUnknownMemberType)
I think it's related to typing.io being removed in python 3.13? (I just tried 3.12.9 -- same error)
If I change it to
def load(
fp: IO[str],
*,
encoding: Optional[str] = None,
...
The error goes away. I'm not positive this is the right fix though :-)
Never mind. it's a "strict" pyright check. I'll turn it off.
Looks like it's something that can be fixed or improved, though. I'll reopen it. Thanks for reporting!