[New-bugs-announce] [issue33539] Remove `init` flag from @dataclass?

Barry A. Warsaw report at bugs.python.org
Wed May 16 10:53:13 EDT 2018


New submission from Barry A. Warsaw <barry at python.org>:

In reading over the new dataclasses documentation, I'm unsure what the `init` flag is used for, given that:

* If you already have a __init__(), then dataclasses won't add one
* If you don't have a __init__(), why wouldn't you want dataclasses to add one?  Without that, how do your attributes get initialized?

If there is a valid use case for `init`, I'm happy to add it to the documentation.  If there isn't, can we call YAGNI and remove the flag?

I'm mildly of the same opinion with `repr` but I can see some value in wanting to defer to object.__repr__().  OTOH, it should be pretty easy to just write:

@dataclass
class Foo:
    def __repr__(self):
        return super.__repr__()

----------
assignee: eric.smith
messages: 316812
nosy: barry, eric.smith, gvanrossum
priority: normal
severity: normal
status: open
title: Remove `init` flag from @dataclass?
versions: Python 3.7, Python 3.8

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


More information about the New-bugs-announce mailing list