Skip to content

New frozendict __init__ annotated improperly #15985

Description

@JoniKauf

Currently __init__ of the new frozendict type is annotated only as def __init__(self) -> None: ....

This causes type checkers to show the following error when trying to create a frozendict with any arguments:
Expected 0 positional arguments.

The entire __init__ and __new__ overloads section currently looks like this:

if sys.version_info >= (3, 15):
    @disjoint_base
    class frozendict(Mapping[_KT, _VT]):
        @overload
        def __new__(cls, /) -> frozendict[Any, Any]: ...
        @overload
        def __new__(cls: type[frozendict[str, _VT]], /, **kwargs: _VT) -> frozendict[str, _VT]: ...
        @overload
        def __new__(cls, map: SupportsKeysAndGetItem[_KT, _VT], /) -> frozendict[_KT, _VT]: ...
        @overload
        def __new__(
            cls: type[frozendict[str, _VT]], map: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT
        ) -> frozendict[str, _VT]: ...
        @overload
        def __new__(cls, iterable: Iterable[tuple[_KT, _VT]], /) -> frozendict[_KT, _VT]: ...
        @overload
        def __new__(
            cls: type[frozendict[str, _VT]], iterable: Iterable[tuple[str, _VT]], /, **kwargs: _VT
        ) -> frozendict[str, _VT]: ...

        def __init__(self) -> None: ...

Fix: __init__ should simply be removed entirely, similar to how it is implemented for frozenset and the __new__ overloads should just stay as they are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions