Skip to content

0.740 doesn't understand abstract properties #7760

Closed
@hukkin

Description

@hukkin

Running mypy 0.740 with check_untyped_defs = True gives a false positive
mypy_bug.py:12: error: "Callable[[AbstractBase], Dict[Any, Any]]" has no attribute "values"
when running against the code below:

from abc import ABC, abstractmethod


class AbstractBase(ABC):
    @property
    @abstractmethod
    def SOME_DICT(self) -> dict:
        pass

    @classmethod
    def get_dict_values(cls):
        return cls.SOME_DICT.values()


class Implementation(AbstractBase):
    SOME_DICT = {"some": "data"}

Mypy thinks that the value of cls.SOME_DICT on line 12 is Callable[[AbstractBase], Dict[Any, Any]], even though it is a property, typehinted to be dict.

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