Skip to content

Can't declare a property setter on a child class without declaring getter there as well #4644

@elvslv

Description

@elvslv

If I declare a property getter on a base class, I can't declare a setter on a child class without having to add a getter there as well.

For example,

class A(object):
    __metaclass__ = ABCMeta

    @property
    def prop(self):
        # type: () -> int
        return 1

class B(A):
    @A.prop.setter
    def prop(self, val):
        # type: (int) -> None
        pass

is a valid python code, but mypy fails with "Callable[[A], int]" has no attribute "setter"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions