classification
Title: Add `module`/`qualname` arguments to make_dataclass for picklability
Type: Stage: patch review
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Antony.Lee, eric.smith, levkivskyi, remi.lapeyre
Priority: normal Keywords: patch, patch

Created on 2018-11-13 14:30 by Antony.Lee, last changed 2018-12-30 20:36 by remi.lapeyre.

Pull Requests
URL Status Linked Edit
PR 11371 open remi.lapeyre, 2018-12-30 20:06
PR 11371 open remi.lapeyre, 2018-12-30 20:06
Messages (2)
msg329847 - (view) Author: Antony Lee (Antony.Lee) * Date: 2018-11-13 14:30
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).
msg332761 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2018-12-30 20:36
Hi @Anthony.Lee, the __module__ is wrong indeed. The new changeset in https://github.com/python/cpython/pull/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.
History
Date User Action Args
2018-12-30 20:36:24remi.lapeyresetnosy: + remi.lapeyre
messages: + msg332761
2018-12-30 20:06:58remi.lapeyresetkeywords: + patch
stage: patch review
pull_requests: + pull_request10711
2018-12-30 20:06:51remi.lapeyresetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10710
2018-11-16 21:38:56levkivskyisetnosy: + levkivskyi
2018-11-13 18:35:28xtreaksetnosy: + eric.smith
2018-11-13 14:30:46Antony.Leecreate