Why does PyCharm give a warning here?
Answered
I have some code here, which throws a warning about an instance attribute being defined outside of __init__, shouldn't that warning be supressed by default if @property/@x.setter decorated is used?
class A:
def __init__(self, x):
self.x = x
@property
def x(self):
return self._x
@x.setter
def x(self, value):
self._x = min(1000, value) # Instance attribute __x defined outside __init__
a = A(9999)
print(a.x) # -> 1000
Please sign in to leave a comment.
Hi Rrebase! This is a known problem: PY-25263. Please vote for this issue.