FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

MappedAsDataclass, prohibit constructor use and/or creation for non-mapped classes, abstract, mixins · Issue #10064 · sqlalchemy/sqlalchemy · GitHub

Repository navigation

MappedAsDataclass, prohibit constructor use and/or creation for non-mapped classes, abstract, mixins #10064

Open

Description

see #10027. MappedAsDataclass basically cannot support the dataclass "init" feature on a class that isn't mapped, and likely can't support any dataclass features on such a class as instantiated. Propose instantiation of mixins / abstract emit a warning if they are also "dataclass" produced under 2.0, error in 2.1.

Activity

  1. added
    bugSomething isn't working
    near-term releaseaddition to the milestone which indicates this should be in a near-term release
    orm - annotated declarativeissues with the new annotations-based declarative ORM approach
    on Jul 5, 2023
  2. added this to the 2.0.x milestone on Jul 5, 2023
  3. removed
    near-term releaseaddition to the milestone which indicates this should be in a near-term release
    on Jul 20, 2023
  4. VimalN2005 commented on Sep 12, 2026

    Hi @zzzeek,

    I'd like to take this on.

    For unmapped mixin and abstract classes transformed by _UnmappedDataclassConfig, we can wrap or replace the generated init with a check that emits an SAWarning (or raises in 2.1) if the abstract/mixin class is directly instantiated, while allowing concrete mapped subclasses to generate their proper dataclass constructor.

    Could you please add the "open for pull requests" label if you'd like a PR for this?

  5. zzzeek commented on Sep 12, 2026

    MemberAuthor

    sure....let's just have this warn in 2.1 for now

  6. modified the milestones: 2.0.x, 2.1 on Sep 12, 2026
  7. added
    code review in progresscode has been provided that's in review as PR and/or gerrit
    and removed
    open for pull requestsMaintainers have approved this issue for an outside pull request
    on Sep 12, 2026
  8. VimalN2005 commented on Sep 12, 2026

    Thanks @zzzeek! Having it emit an SAWarning in 2.1 makes total sense. I've aligned the implementation and opened the PR for review.

  9. sqla-tester commented on Sep 24, 2026

    Collaborator

    VimalN2005 has proposed a fix for this issue in the main branch:

    Emit warning on direct instantiation of unmapped MappedAsDataclass https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/6991

  10. added a commit that references this issue on Sep 24, 2026
    c72f83b
  11. zzzeek commented on Sep 24, 2026

    MemberAuthor

    we're in RCs for 2.1 and I want to hold on this one until post-2.1. once 2.1 is smooth sailing we can look at a warning for this

  12. modified the milestones: 2.1, 2.1.x on Sep 24, 2026
  13. added a commit that references this issue on Sep 24, 2026
    6031fac
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

    bugSomething isn't workingcode review in progresscode has been provided that's in review as PR and/or gerritdataclassesorm - annotated declarativeissues with the new annotations-based declarative ORM approach

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL