Skip to content

Add module/qualname arguments to make_dataclass for picklability #79413

Description

@anntzer
mannequin
BPO 35232
Nosy @ericvsmith, @ilevkivskyi, @csabella, @remilapeyre
PRs
  • gh-79413: Add module and qualname arguments to dataclasses.make_dataclass() #11371
  • gh-79413: Add module and qualname arguments to dataclasses.make_dataclass() #11371
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2018-11-13.14:30:46.300>
    labels = ['3.7', '3.8', '3.9', '3.10', 'type-feature', 'library']
    title = 'Add `module`/`qualname` arguments to make_dataclass for picklability'
    updated_at = <Date 2020-06-21.00:43:53.291>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2020-06-21.00:43:53.291>
    actor = 'remi.lapeyre'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2018-11-13.14:30:46.300>
    creator = 'Antony.Lee'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35232
    keywords = ['patch', 'patch']
    message_count = 3.0
    messages = ['329847', '332761', '342283']
    nosy_count = 4.0
    nosy_names = ['eric.smith', 'levkivskyi', 'cheryl.sabella', 'remi.lapeyre']
    pr_nums = ['11371', '11371']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue35232'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

    Linked PRs

    Activity

    1. anntzer commented on Nov 13, 2018

      anntzermannequin
      MannequinAuthor

      Currently, dataclasses created by make_dataclass are not picklable, because their module is set to "types". It seems that this would be easily fixed by letting make_dataclass gain a module and a qualname kwarg, similarly to the Enum functional form (https://docs.python.org/3/library/enum.html#functional-api).

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Nov 13, 2018
    3. remilapeyre commented on Dec 30, 2018

      remilapeyremannequin
      Mannequin

      Hi @Anthony.Lee, the __module__ is wrong indeed. The new changeset in #11371 should implement what you need.

      If you don't specify the new module and qualname parameters, make_dataclass() will try to determine the correct module so you should not need to change your code.

    4. added
      type-featureA feature request or enhancement
      and removed on Apr 11, 2019
    5. csabella commented on May 13, 2019

      @csabella
      Contributor

      @eric.smith Can you take a look at this when you get a chance? Thanks!

    6. transferred this issue fromon Apr 10, 2022
    7. remilapeyre commented on Apr 11, 2024

      @remilapeyre
      Contributor

      The module part of this has been separately reported at #102103 and fixed in #102104.

      Do we need to take care of qualname still? If so I will update my pull request at #11371, otherwise we can close both this issue and its pull-request.

    8. encukou commented on Sep 2, 2025

      @encukou
      Member

      Adding qualname would make sense to me, if you're still up to it.

    9. ericvsmith commented on Sep 16, 2025

      @ericvsmith
      Member

      Agreed. @remilapeyre: Could you take a look at adding qualname? And would this not also apply to namedtuple?

    10. added a commit that references this issue on May 18, 2026
    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

      stdlibStandard Library Python modules in the Lib/ directorytopic-dataclassestype-featureA feature request or enhancement

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions