GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Dataclasses without `__init__` no longer work in 3.14.1 due to #137711 · Issue #142214 · python/cpython

Dataclasses without __init__ no longer work in 3.14.1 due to #137711 #142214

New issue
Copy link
New issue
Copy link
Closed
Closed
Dataclasses without __init__ no longer work in 3.14.1 due to #137711#142214
Copy link
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-dataclassestopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@emontnemery
emontnemery
opened on Dec 3, 2025
Issue body actions

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.

from dataclasses import dataclass, field

@dataclass(slots=True, init=False)
class MyClass:
    attr: int

    def __new__(cls, attr: int) -> Self:
        self.attr = attr
        return self

Error message:

$ python3 dataclasses_issue.py
Traceback (most recent call last):
  File "/home/erik/dataclasses_issue.py", line 3, in <module>
    @dataclass(slots=True, init=False)
     ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/erik/.pyenv/versions/3.14.1/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 "/home/erik/.pyenv/versions/3.14.1/lib/python3.14/dataclasses.py", line 1234, in _process_class
    cls = _add_slots(cls, frozen, weakref_slot, fields)
  File "/home/erik/.pyenv/versions/3.14.1/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__'?

CPython versions tested on:

3.14.1

Operating systems tested on:

Linux

Linked PRs

  • gh-142214: Fix two regressions in dataclasses #142223
  • [3.14] gh-142214: Fix two regressions in dataclasses (GH-142223) #142277
Reacted by Giulio Mazzanti, Robert Resch, SamWarden, Bas Nijholt, ADBond, Oleksandr Kravets, Barak Ugav, Radomir Stevanovic, Alex Kennedy, Alfredo Luque and 6 more

Activity

Next
  1. emontnemery
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Dec 3, 2025
  2. emontnemery
    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
  3. dpinol commented on Dec 3, 2025

    @dpinol
    dpinol
    on Dec 3, 2025
    More actions

    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, Aryazaky and Lenormand Julien
    Reacted by Ross Barnowski and Oleksandr Kravets
  4. Giuzzilla commented on Dec 3, 2025

    @Giuzzilla
    Giuzzilla
    on Dec 3, 2025
    More actions

    Python 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'
  5. pareshjoshij commented on Dec 3, 2025

    @pareshjoshij
    pareshjoshij
    on Dec 3, 2025
    Contributor
    More actions

    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?

  6. sobolevn commented on Dec 3, 2025

    @sobolevn
    sobolevn
    on Dec 3, 2025
    Member
    More actions

    Also got this error today: https://github.com/wemake-services/django-modern-rest/actions/runs/19889091191/job/57003155723

  7. sobolevn
    added
    topic-typing
    topic-dataclasses
    on Dec 3, 2025
  8. pareshjoshij commented on Dec 3, 2025

    @pareshjoshij
    pareshjoshij
    on Dec 3, 2025
    Contributor
    More actions

    @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.

  9. terryjreedy
    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
  10. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    release-blocker
    on Dec 3, 2025
  11. github-project-automation
    added this to Release and Deferred blockers 🚫on Dec 3, 2025
  12. 20 remaining items

  13. ewels
    added a commit that references this issue on Dec 5, 2025

    Avoid Python 3.14.1

    bd01d4f
  14. hugovk commented on Dec 5, 2025

    @hugovk
    hugovk
    on Dec 5, 2025
    Member
    More actions

    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, Yz, Ross Barnowski and robinechuca
    Reacted by Alex Waygood, Chenxin Zhong, Srinivas Gorur-Shandilya, Jens Tonberg Larsson, Ross Barnowski and ADBond
  15. hugovk
    closed this as completedon Dec 5, 2025
  16. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on Dec 5, 2025
  17. rossbar
    added a commit that references this issue on Dec 5, 2025

    DEP: blocklist 3.14.1

    973d5ed
  18. StanFromIreland
    added a commit that references this issue on Dec 6, 2025

    pythongh-142214: Fix two regressions in dataclasses (python#142223)

    3265f88
  19. MridulS
    added a commit that references this issue on Dec 7, 2025

    Blocklist Python 3.14.1 (#8372)

    c38830c
  20. fedarko
    added a commit that references this issue on Dec 8, 2025

    Add Python 3.14 back to CI matrix

    b67c275
  21. wimglenn commented on Dec 10, 2025

    @wimglenn
    wimglenn
    on Dec 10, 2025
    Contributor
    More actions

    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.14 in .github/workflows which automatically picked up the micro bump on Dec 2 and CIs got trashed (fortunately the fix was trivial just pinning it to 3.14.0 in the workflow yaml).

  22. hugovk commented on Dec 10, 2025

    @hugovk
    hugovk
    on Dec 10, 2025
    Member
    More actions

    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 Stinner
  23. zzzeek commented on Dec 10, 2025

    @zzzeek
    zzzeek
    on Dec 10, 2025
    More actions

    a 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).

  24. encukou commented on Dec 10, 2025

    @encukou
    encukou
    on Dec 10, 2025
    Member
    More actions

    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
  25. alexlancaster
    added 2 commits that reference this issue on Dec 11, 2025

    conditionally pin macos builds to 3.14.0

    07b2178

    Temporary pin of Python 3.14.0 to work around upstream bug (#113)

    24c0b10
  26. hugovk commented on Feb 2, 2026

    @hugovk
    hugovk
    on Feb 2, 2026
    Member
    More actions

    Reported @stomde to GitHub.

    Reacted by Alex Waygood
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-dataclassestopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • Release and Deferred blockers 🚫
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.