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

Setter and getter method names can't differ (Python 2) #8086

Closed
JukkaL opened this issue Dec 5, 2019 · 1 comment
Closed

Setter and getter method names can't differ (Python 2) #8086

JukkaL opened this issue Dec 5, 2019 · 1 comment
Labels
false-positive mypy gave an error on correct code feature priority-2-low topic-descriptors Properties, class vs. instance attributes topic-python2 issues only applicable to Python 2

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Dec 5, 2019

This doesn't work (reported by Tim Abbott):

class C:
    def __init__(self) -> None:
        self._x = 0

    @property
    def x(self) -> int:
        return self._x

    @x.setter
    def set_x(self, value: int) -> None:   # Note the name of the method! "def x" works.
        self._x = value

This example seems to be only valid in Python 2, not Python 3.

(Originally reported in #220 (comment).)

@JukkaL JukkaL added feature priority-1-normal false-positive mypy gave an error on correct code labels Dec 5, 2019
@AlexWaygood AlexWaygood added priority-2-low topic-descriptors Properties, class vs. instance attributes topic-python2 issues only applicable to Python 2 and removed priority-1-normal labels Mar 25, 2022
@JukkaL
Copy link
Collaborator Author

JukkaL commented Mar 31, 2022

Closing due to Python 2 feature freeze (#12237).

@JukkaL JukkaL closed this as completed Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive mypy gave an error on correct code feature priority-2-low topic-descriptors Properties, class vs. instance attributes topic-python2 issues only applicable to Python 2
Projects
None yet
Development

No branches or pull requests

2 participants