You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add module/qualname arguments to make_dataclass for picklability #79413
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).
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.
Activity
anntzer commentedon Nov 13, 2018
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
moduleand aqualnamekwarg, similarly to the Enum functional form (https://docs.python.org/3/library/enum.html#functional-api).remilapeyre commentedon Dec 30, 2018
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
moduleandqualnameparameters, make_dataclass() will try to determine the correctmoduleso you should not need to change your code.csabella commentedon May 13, 2019
@eric.smith Can you take a look at this when you get a chance? Thanks!
remilapeyre commentedon Apr 11, 2024
The
modulepart of this has been separately reported at #102103 and fixed in #102104.Do we need to take care of
qualnamestill? If so I will update my pull request at #11371, otherwise we can close both this issue and its pull-request.encukou commentedon Sep 2, 2025
Adding
qualnamewould make sense to me, if you're still up to it.ericvsmith commentedon Sep 16, 2025
Agreed. @remilapeyre: Could you take a look at adding
qualname? And would this not also apply tonamedtuple?gh-79413: Add `qualname` parameter to `dataclass.make_dataclass`. (GH…