dataclasses
dataclasses copied to clipboard
Basically, [this issue](https://github.com/python-attrs/attrs/issues/102) with attrs also applies to dataclasses. Trying to run this code ```python from dataclasses import dataclass @dataclass(slots=True) class Base: def hi(self): print("Hi") @dataclass(slots=True) class Sub(Base): def hi(self):...
bpo-34363: dataclasses.asdict() and .astuple() now handle fields which are namedtuples https://github.com/python/cpython/commit/9b9d97dd139a799d28ff8bc90d118b1cac190b03
This is the same issue as https://bugs.python.org/issue36470, I open a new issue here for greater visibility. Basically if one has a dataclass which defines an `InitVars` with a default value,...
With the new py version restriction, pip will now as a result install dataclasses 0.6 if install is attempted on py37, since this is the last available version that satisfies...
It seems the fix of https://bugs.python.org/issue34363 is missing in `dataclasses` version `0.7` backported to `python 3.6` ~~~python # 3.6.8 (default, Feb 28 2019, 22:12:13) # [GCC 8.2.1 20181127](6, 0, 1)...
Although not part of the official API, I find `add_slots` to be quite useful. However, the combination with frozen dataclasses and pickling causes problems: ```python @add_slots @dataclass(frozen=True) class ExampleDataclass: foo:...
https://bugs.python.org/issue35540 is the official bug report on the stdlib implementation in 3.7, copied below. There's a proposed fix at https://github.com/python/cpython/pull/11361 to special-case `defaultdict`. > _asdict_inner attempts to manually recursively deepcopy...
The tag last-version-with-ast points to a version of the code that uses ast to create functions. The current master branch uses exec.
For example: ```python @dataclass class Trie: r"""Trie.""" range: Range parent: "Trie | None" = None value: dict[str, "Trie"] | list["Trie"] | str | int | float | None = None...
> New in version 3.10. > kw_only: If true (the default value is False), then all fields will be marked as keyword-only. If a field is marked as keyword-only, then...