You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from dataclasses import dataclass
@dataclass
class T:
x: str
def __post_init__(self):
self.s = 1
print(self.s)
@dataclass
class TT(T):
def foo(self):
print(self.s)
will give:
b.py.T has no attribute 's' (code: undefined_attribute)
In b.py at line 9
6:
7: def __post_init__(self):
8: self.s = 1
9: print(self.s)
^
10:
11: @dataclass
12: class TT(T):
b.py.TT has no attribute 's' (code: undefined_attribute)
In b.py at line 14
11: @dataclass
12: class TT(T):
13: def foo(self):
14: print(self.s)
^
If the subclass is not a dataclass, you don't get the second complaint
The text was updated successfully, but these errors were encountered:
Do you think __post_init__ should be special here? Pyanalyze generally assumes dataclasses have only those attributes defined as fields, because in general it's currently very hard to detect undefined attributes. So I might not want to change this until I have a more solid way to detect undefined attributes in general. That's something I've been thinking about, but it would be a big change.
will give:
If the subclass is not a dataclass, you don't get the second complaint
The text was updated successfully, but these errors were encountered: