Skip to content

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

Closed as not planned

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"

Activity

  1. JukkaL commented on Feb 27, 2018

    @JukkaL
    Collaborator

    Yes, it would be nice if mypy supported this idiom.

  2. AlexWaygood commented on Jan 9, 2023

    @AlexWaygood
    Member

    Closing in favour of #5936, which was filed after this issue, but has had more activity on it since.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions