[issue36424] Pickle fails on frozen dataclass that has slots

2021-10-13 Thread David Hagen
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 3.10

[issue39442] from __future__ import annotations makes dataclasses.Field.type a string, not type

2020-01-24 Thread David Hagen
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

[issue34776] Postponed annotations break inspection of dataclasses

2019-10-23 Thread David Hagen
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

[issue36424] Pickle fails on frozen dataclass that has slots

2019-03-25 Thread David Hagen
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

[issue34776] Postponed annotations break inspection of dataclasses

2018-09-23 Thread David Hagen
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 real

[issue31385] `import as` does not work when module has same same as parent module

2017-09-07 Thread David Hagen
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

[issue26988] Add AutoNumberedEnum to stdlib

2016-08-19 Thread David Hagen
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

[issue26988] Add AutoNumberedEnum to stdlib

2016-08-17 Thread David Hagen
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 named objects of