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

non-contiguous @property definitions don't work #1713

Closed
ddfisher opened this issue Jun 15, 2016 · 4 comments
Closed

non-contiguous @property definitions don't work #1713

ddfisher opened this issue Jun 15, 2016 · 4 comments

Comments

@ddfisher
Copy link
Collaborator

Mypy's parser combines all contiguous decorated function definitions with the same name into an OverloadedFuncDef. Mypy relies on this behavior later e.g. when understanding @Property checks.

So if you write:

class C:
  @property
  def x(self) -> str: pass

  z = 0  # or any other irrelevant definition

  @x.setter
  def x(self, str) -> None: pass

mypy complains:

test.py: note: In class "C":
test.py:7: error: Callable[[C], str] has no attribute "setter"
@ddfisher
Copy link
Collaborator Author

Came across this while investigating #1708.

@ddfisher
Copy link
Collaborator Author

I'm pretty sure this will also be a problem if e.g. the setter method has a different name.

@carljm
Copy link
Member

carljm commented Jun 4, 2017

This is a duplicate of #1465.

@ilevkivskyi
Copy link
Member

Indeed, this looks like a duplicate.

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

3 participants