David Hagen added the comment:
Because the implementation in GH-25786 relies on the new
`dataclass(slots=True)` feature (i.e. it does not work if the slots are
specified with `__slots__`), I don't think this can be trivially backported to
versions before
David Hagen added the comment:
Should `dataclass.Field.type` become a property that evaluates the annotation
at runtime much in the same way that `get_type_hints` works?
--
nosy: +drhagen
___
Python tracker
<https://bugs.python.org/issue39
David Hagen added the comment:
This PR has been sitting for a while. Any chance we can bring it over the
finish line?
--
___
Python tracker
<https://bugs.python.org/issue34
New submission from David Hagen :
If a dataclass is `frozen` and has `__slots__`, then unpickling an instance of
it fails because the default behavior is to use `setattr` which `frozen` does
not allow.
```
import pickle
from dataclasses import dataclass
@dataclass(frozen=True)
class A
New submission from David Hagen :
The new postponed annotations have an unexpected interaction with dataclasses.
Namely, you cannot get the type hints of any of the data classes methods.
For example, I have some code that inspects the type parameters of a class's
`__init__` method. (The
New submission from David Hagen:
Consider the following Python project:
bugtest/
__init__.py (Contents: from .foo import *)
foo/
__init__.py (Contents: from .foo import *)
foo.py (Contents: )
Then in a Python session, the following line executes without error (as
expected
David Hagen added the comment:
One solution similar to one proposed by Vedran works with the current Enum:
class Color(Enum):
red = object()
green = object()
blue= object()
I tested this in PyCharm and it is perfectly happy with the autocomplete and
everything. The
David Hagen added the comment:
> Secondarily, the doesn't seem to be any use case that can't be readily
> covered by the existing classes.
The use case that doesn't have a clean interface in 3.5 at the moment is the
most common use case of enums: just a collection of n