-
-
Notifications
You must be signed in to change notification settings - Fork 402
Open
Description
Today I stumbled over this one:
from attrs import define,field
from dataclasses import dataclass
@define
class N1:
foo:int|None = field(default=None)
class N2:
foo:int|None = None
def __init__(self, foo):
self.foo = 123
@dataclass
class N3:
foo:int|None = None
n3 = N3(foo=123)
del n3.foo
assert n3.foo is None
n2 = N2(foo=123)
del n2.foo
assert n2.foo is None
n1 = N1(foo=123)
del n1.foo
n1.foo # AttributeError
This is not what I'd expect when I decide to attrs-ize an existing class. Thus please either fix this, or add a reasonably prominent section that documents this (and other possible pitfalls) to the manual.
Metadata
Metadata
Assignees
Labels
No labels