Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
elvslv opened this issue Feb 27, 2018 · 2 comments
Labels
feature priority-1-normal topic-descriptors Properties, class vs. instance attributes topic-inheritance Inheritance and incompatible overrides topic-runtime-semantics mypy doesn't model runtime semantics correctly

Comments

@elvslv
Copy link

elvslv commented Feb 27, 2018

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"

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 27, 2018

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

@AlexWaygood AlexWaygood added topic-descriptors Properties, class vs. instance attributes topic-inheritance Inheritance and incompatible overrides topic-runtime-semantics mypy doesn't model runtime semantics correctly labels Mar 27, 2022
@AlexWaygood
Copy link
Member

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

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature priority-1-normal topic-descriptors Properties, class vs. instance attributes topic-inheritance Inheritance and incompatible overrides topic-runtime-semantics mypy doesn't model runtime semantics correctly
Projects
None yet
Development

No branches or pull requests

3 participants