[issue45366] dataclass init=False field with default works but default_factory does not

2021-10-04 Thread simple_coder878
New submission from simple_coder878 : Simple example from dataclasses import dataclass, field @dataclass(init=False) class TestObject(object): m: str = field(default='hi') k: list = field(default_factory=list) def test(self): print(f'm is {self.m} ')

[issue45366] dataclass init=False field with default works but default_factory does not

2021-10-04 Thread simple_coder878
simple_coder878 added the comment: Also wanted to add that I did try another variation of the first example where I set the default_factory field's init value to False and I got the same error. from dataclasses import dataclass, field @dataclass(init=False) class TestObject(object):