Skip to content

We wish the key type could also be covariant, but that doesn't work, #274

Description

@github-actions

see discussion in https://github\.com/python/typing/pull/273\.

@AbstractMethod

# TODO: We wish the key type could also be covariant, but that doesn't work,
# see discussion in https://github.com/python/typing/pull/273.
# @abstractmethod

    key/value pairs.
    """

    # TODO: We wish the key type could also be covariant, but that doesn't work,
    # see discussion in https://github.com/python/typing/pull/273.
    # @abstractmethod
    def __getitem__(self, key: _KT, /) -> _VT_co: raise AssumedToBeImplementedException

    # Mixin methods
    @overload
    def get(self, key: _KT, /) -> _VT_co | None: raise AssumedToBeImplementedException
    @overload
    def get(self, key: _KT, default: _VT_co, /) -> _VT_co: raise AssumedToBeImplementedException  # type: ignore[misc]
    @overload
    def get(self, key: _KT, default: _T, /) -> _VT_co | _T: raise AssumedToBeImplementedException
    def get(self, key: _KT, default: None | _VT_co | _T = None, /) -> _VT_co | _T | None:
        """
        D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
        """
        raise AssumedToBeImplementedException

    # # def items(self) -> ItemsView[_KT, _VT_co]: ...
    # def items(self) -> IsItemsView[_KT, _VT_co]:
    #     """
    #     D.items() -> a set-like object providing a view on D's items

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions