equinox
equinox copied to clipboard
Class fields and instance fields behavior
Hello, Patrick
currently, data classes allow fields to be either class or instance variables for example
@dc.dataclass
class Test:
a:int = 1
def __init__(self) -> None:
pass
Test().__dict__ # {}
Test.__dict__['a'] # 1 -> class variable
I think it is better to log a warning or to raise an uninitialized field error to disallow this behavior. As the user might be under the impression that a
is a parameter of the Test
instance (as shown in the Test repr
) while it's not.