5 ms·
I personally just use `dataclass(kw_only=True)`, which should really be the default in most cases anyways.
by saiojd 4y ago
I personally just use `dataclass(kw_only=True)`, which should really be the default in most cases anyways.
- conaclos 4y agoI think the same. `slots=True` should also be the default.
- goodoldneon 4y agoNice, I think kw_only=True and slots=True solve a lot of my dataclass problems. Wish they defaulted to true
- conaclos 4y ago`frozen=True` is really nice also if your data does not change :)
- dragonwriter 4y ago> Nice, I think kw_only=True and slots=True solve a lot of my dataclass problems. Wish they defaulted to true While it doesn’t solve reading other people’s code with the defaults you’d like to have, dataclass being a decorator and not a special syntax means that you can just derive a new decorator from it with the defaults you want.
- conaclos 4y ago> you can just derive a new decorator from it with the defaults you want. This could hurt basic static analysis.
- dragonwriter 4y ago> This could hurt basic static analysis. That’s a good point. I know some of the python static analysis tools can “see through” some simple indirection, but don't know if even a simple wrapper injecting arguments would work with any (or which) of them for this purpose.
- saiojd 4y agoIt's ugly but you can fix this with `dataclass_transform`