Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
The resolution for#137530,#137711 which was backported to 3.14 and included in 3.14.1, breaks dataclasses without__init__.
Although a dataclass without__init__ doesn't seem that helpful, it doesn't seem to be explicitly forbidden and shouldn't break in a point release.
fromdataclassesimportdataclass,field@dataclass(slots=True,init=False)classMyClass:attr:intdef__new__(cls,attr:int)->Self:self.attr=attrreturnself
Error message:
$ python3 dataclasses_issue.pyTraceback (most recent call last): File"/home/erik/dataclasses_issue.py", line3, in<module>@dataclass(slots=True,init=False)~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File"/home/erik/.pyenv/versions/3.14.1/lib/python3.14/dataclasses.py", line1426, inwrapreturn _process_class(cls, init,repr, eq, order, unsafe_hash, frozen, match_args, kw_only, slots, weakref_slot) File"/home/erik/.pyenv/versions/3.14.1/lib/python3.14/dataclasses.py", line1234, in_process_classcls= _add_slots(cls, frozen, weakref_slot, fields) File"/home/erik/.pyenv/versions/3.14.1/lib/python3.14/dataclasses.py", line1401, in_add_slots init_annotate= newcls.__init__.__annotate__^^^^^^^^^^^^^^^^^^^^^^^^^^^^AttributeError:'wrapper_descriptor' object has no attribute '__annotate__'. Did you mean: '__getstate__'?
CPython versions tested on:
3.14.1
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done