Repository navigation
Dataclasses without __init__ no longer work in 3.14.1 due to #137711 #142214
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Dec 3, 2025 - changed the title
[-]Dataclasses without __init__ no longer work due to #137711[/-][+]Dataclasses without __init__ no longer work in 3.14.1 due to #137711[/+]on Dec 3, 2025 as an example, it breaks networkx 3.6
File "/usr/local/lib/python3.14/site-packages/networkx/utils/configs.py", line 8, in <module> @dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False) ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.14/dataclasses.py", line 1426, in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, match_args, kw_only, slots, weakref_slot) File "/usr/local/lib/python3.14/dataclasses.py", line 1234, in _process_class cls = _add_slots(cls, frozen, weakref_slot, fields) File "/usr/local/lib/python3.14/dataclasses.py", line 1401, in _add_slots init_annotate = newcls.__init__.__annotate__ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'wrapper_descriptor' object has no attribute '__annotate__'. Did you mean: '__getstate__'?
Reacted by Vladimir Vargas-Calderón, clayote, Oleksandr Kravets, Barak Ugav, Wim Jeantine-Glenn and AryazakyReacted by Ross Barnowski and Oleksandr KravetsPython 3.14.1 is breaking my sqlalchemy-based project as well, seems related to the issue/dataclasses, stacktrace:
mypackage/mymodel.py:109: in <module> class MyModel(Base, kw_only=True): .venv/lib/python3.14/site-packages/sqlalchemy/orm/decl_api.py:626: in __init_subclass__ super().__init_subclass__(**kw) .venv/lib/python3.14/site-packages/sqlalchemy/orm/decl_api.py:846: in __init_subclass__ _as_declarative(cls._sa_registry, cls, cls.__dict__) .venv/lib/python3.14/site-packages/sqlalchemy/orm/decl_base.py:245: in _as_declarative return _MapperConfig.setup_mapping(registry, cls, dict_, None, {}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/sqlalchemy/orm/decl_base.py:326: in setup_mapping return _ClassScanMapperConfig( .venv/lib/python3.14/site-packages/sqlalchemy/orm/decl_base.py:564: in __init__ self._setup_dataclasses_transforms() .venv/lib/python3.14/site-packages/sqlalchemy/orm/decl_base.py:1171: in _setup_dataclasses_transforms self._apply_dataclasses_to_any_class( .venv/lib/python3.14/site-packages/sqlalchemy/orm/decl_base.py:1227: in _apply_dataclasses_to_any_class dataclass_callable( # type: ignore[call-overload] /usr/local/lib/python3.14/dataclasses.py:1436: in dataclass return wrap(cls) ^^^^^^^^^ /usr/local/lib/python3.14/dataclasses.py:1426: in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, /usr/local/lib/python3.14/dataclasses.py:1217: in _process_class text_sig = str(inspect.signature( /usr/local/lib/python3.14/inspect.py:3321: in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped, /usr/local/lib/python3.14/inspect.py:3036: in from_callable return _signature_from_callable(obj, sigcls=cls, /usr/local/lib/python3.14/inspect.py:2557: in _signature_from_callable return _get_signature_of(init) ^^^^^^^^^^^^^^^^^^^^^^^ /usr/local/lib/python3.14/inspect.py:2440: in _signature_from_callable sig = _get_signature_of(obj.__func__) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/local/lib/python3.14/inspect.py:2511: in _signature_from_callable return _signature_from_function(sigcls, obj, /usr/local/lib/python3.14/inspect.py:2334: in _signature_from_function annotations = get_annotations(func, globals=globals, locals=locals, eval_str=eval_str, /usr/local/lib/python3.14/annotationlib.py:973: in get_annotations ann = _get_and_call_annotate(obj, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/local/lib/python3.14/annotationlib.py:1112: in _get_and_call_annotate ann = call_annotate_function(annotate, format, owner=obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/local/lib/python3.14/annotationlib.py:711: in call_annotate_function return annotate(format) ^^^^^^^^^^^^^^^^ /usr/local/lib/python3.14/dataclasses.py:553: in __annotate__ new_annotations[k] = cls_annotations[k] ^^^^^^^^^^^^^^^^^^ E KeyError: 'my_field'Looks like we're seeing two different side effects from the recent annotation updates.
1 The NetworkX crash: It seems init=False exposes object.init (a wrapper descriptor), which naturally lacks annotate.
2 The SQLAlchemy KeyError: It looks like the code assumes every field must exist in cls_annotations. That assumption might be too strict for dynamic classes where attributes are injected.
I suspect adding guards in both spots to handle missing attributes/keys would fix this?
Also got this error today: https://github.com/wemake-services/django-modern-rest/actions/runs/19889091191/job/57003155723
@epenet that link speaks volumes.
The fact that they had to rush that merge to unblock CI—even skipping the documentation steps you suggested—really confirms how severe the instability is for downstream users.
- changed the title
[-]Dataclasses without __init__ no longer work in 3.14.1 due to #137711[/-][+]Dataclasses without `__init__` no longer work in 3.14.1 due to #137711[/+]on Dec 3, 2025 - addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes
on Dec 3, 2025 20 remaining items
Thanks all, merged and backported, will hopefully be released in 3.14.2 today.
Reacted by David Ellis, Chenxin Zhong, Jens Tonberg Larsson, Alex Kennedy, YerazZ, Ross Barnowski and robinechucaReacted by Alex Waygood, Chenxin Zhong, Srinivas Gorur-Shandilya, Jens Tonberg Larsson, Ross Barnowski and ADBond- moved this from Todo to Done in Release and Deferred blockers 🚫
on Dec 5, 2025 - added a commit that references this issue
on Dec 7, 2025 - added a commit that references this issue
on Dec 8, 2025 I was thinking, could there be something in the CPython release process for maintenance releases which sanity checks that an assortment of heavily used libraries such as networkx and sqlalchemy can successfully import?
That sounds like some low hanging fruit, and something easy to automate for catching potentially disruptive issues before the release is published and gets picked up by various GitHub actions. I had some
uv python install 3.14in .github/workflows which automatically picked up the micro bump on Dec 2 and CIs got trashed (fortunately the fix was trivial just pinning it to3.14.0in the workflow yaml).It's been considered in the past (for example, PEP 608 / https://discuss.python.org/t/rejected-rfc-pep-608-coordinated-python-release/2539 six years ago) but iirc rejected due to the amount of work and diversity of test setups.
I suggest opening a new discussion, though, if you think things are better now to retry it.
Reacted by Victor Stinnera coordinated release seems a little heavy handed, but there's no reason people (anyone, python devs, OSS authors, interested parties) can't run CIs (like a series of github actions somehwere) that test the Python main branch against some series of OSS libraries, and just report github issues for failures that are observed.
CIs like these can be burdensome as when you are tracking the "main" of another project, there's often unrelated problems that get checked into main. plus you have to stay on top of deployment / test runner changes in the project (though cPython is extremely good at staying exactly the same in my experience).
I've been thinking whether the 3.x.1 release needs a RC period, given that all fixes from the long 3.x.0 RC period land there.
Reacted by Itamar Oren- added 2 commits that reference this issue
on Dec 11, 2025 Reported @stomde to GitHub.
Reacted by Alex Waygood
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
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.Error message:
CPython versions tested on:
3.14.1
Operating systems tested on:
Linux
Linked PRs