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

Created on 2018-11-13 14:30 by Antony.Lee, last changed 2019-05-13 03:47 by cheryl.sabella.

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 (3)
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.
msg342283 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-05-13 03:47
@eric.smith   Can you take a look at this when you get a chance?  Thanks!
History
Date User Action Args
2019-05-13 03:47:38cheryl.sabellasetkeywords: patch, patch
nosy: + cheryl.sabella
messages: + msg342283

2019-04-11 13:03:31Antony.Leesetnosy: - Antony.Lee
2019-04-11 12:46:46cheryl.sabellasetkeywords: patch, patch
type: enhancement
versions: + Python 3.8, - Python 3.7
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