Skip to content

Signature of ItemsView in typing.py does not match that in typeshed's typing.pyi #177

Description

@gvanrossum

This came up in #136 (comment).

There seems to be a bug in the definition of ItemsView in typing.py: it has three type parameters, but its unclear what they mean. When looking at the corresponding definition in typeshed, it actually makes more sense:

class MappingView(Sized):
    def __len__(self) -> int: ...

class ItemsView(AbstractSet[Tuple[_KT_co, _VT_co]], MappingView, Generic[_KT_co, _VT_co]):
    def __contains__(self, o: object) -> bool: ...
    def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ...

Here MappingView is not generic (since Sized isn't), and ItemsView has only two parameters, clearly meant for keys and values, and clarified by the __contains__ and __iter__ signatures.

I think we should follow this example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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