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

Mypy expects @property's to follow each other #7263

Closed
mchlnix opened this issue Jul 26, 2019 · 1 comment
Closed

Mypy expects @property's to follow each other #7263

mchlnix opened this issue Jul 26, 2019 · 1 comment

Comments

@mchlnix
Copy link

mchlnix commented Jul 26, 2019

  • Are you reporting a bug, or opening a feature request?
    Bug
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
class Works:
    def __init__(self):
        self._a = 0

    @property
    def a(self):
        return self._a

    @a.setter
    def a(self, value):
        self._a = value


class Doesnt:
    def __init__(self):
        self._a = 0

    @property
    def a(self):
        return self._a

    def another_method(self):
        print("This is unimportant")

    @a.setter
    def a(self, value):
        self._a = value
  • What is the actual behavior/output?
test-mypy.py:25: error: Name 'a' already defined on line 18
test-mypy.py:25: error: "Callable[[Any], Any]" has no attribute "setter"
  • What is the behavior/output you expect?
    That parts of a property definition do not have to follow each other directly to be recognized as such.
  • What are the versions of mypy and Python you are using?
    Python: 3.6.5
    Mypy: 0.720
  • Do you see the same issue after installing mypy from Git master?
    Yes
  • What are the mypy flags you are using? (For example --strict-optional)
    None
@JukkaL
Copy link
Collaborator

JukkaL commented Jul 26, 2019

Closing as duplicate of #1465.

@JukkaL JukkaL closed this as completed Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants