-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Attributes of property objects can't be accessed #8085
Comments
If I understand this correctly, I just ran into an issue related to this. I get a mypy error when overriding a property in a subclass. class Base:
@property
def foo(self):
return self._foo
@foo.setter
def foo(self, val):
self._foo = val
class Sub(Base):
@Base.foo.setter # mypy error
def foo(self, val):
self._foo = val + 1 The error I get:
|
I encountered this issue when trying to use a The following program runs fine, but generates a mypy error: https://gist.github.com/mypy-play/12b11a6d77c3e70413514c4666015aa2 from dataclasses import dataclass
from result import Ok
@dataclass
class Person:
_name: str
@property
def name(self) -> str:
return self._name.title()
person_result = Ok(Person(_name="john doe"))
name_result = person_result.map(Person.name.fget)
name = name_result.value
print(name) I could avoid the false positive by using P.S: Maybe of interest to @sobolevn given the functional patterns at play? 😉 |
A minimal example for clarification: class C:
@property
def p(self) -> int:
return 1
C.p.fget
C.p.fset
C.p.fdel
mypy believes that |
Still an issue a few years later. Can we get this fixed? |
Originally reported by @ilevkivskyi in #220 (comment):
Another thing that doesn't work came in #6045: accessing attributes of a property object in the class body (for example
fset
,fget
etc). This can be probably partially solved by some special casing incheckmember.py
.The text was updated successfully, but these errors were encountered: