[New-bugs-announce] [issue33129] Add kwarg-only option to dataclass

Alan Du report at bugs.python.org
Fri Mar 23 19:33:17 EDT 2018


New submission from Alan  Du <ahd2125 at columbia.edu>:

I'd like to request a new option to the `dataclasses.dataclass` decorator to make the `__init__` keyword-only.

The two use-cases I have in mind are:

(1) Using as a dataclass big-bag-of-config. In this scenario, forcing the user to specify the keywords is a lot nicer than passing in a dozen positional parameters.

(2) Having kwarg-only parameters means that inheritance and default parameters play nicely with each other again instead of raising a TypeError.

----------
components: Library (Lib)
messages: 314341
nosy: alan_du, eric.smith
priority: normal
severity: normal
status: open
title: Add kwarg-only option to dataclass
type: enhancement
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33129>
_______________________________________


More information about the New-bugs-announce mailing list