Skip to content

typing error in python 3.13 #92

@ggilley

Description

@ggilley

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 :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions