[issue36077] Inheritance dataclasses fields and default init statement

Кирилл Чуркин report at bugs.python.org
Fri Feb 22 07:27:13 EST 2019


New submission from Кирилл Чуркин <pirotech97 at gmail.com>:

I found a problem when use inherit dataclasses.
When I define parent dataclass with field(s) with default (or default_factory) properties, and inherit child dataclass from parent, i define non-default field in it and got `TypeError('non-default argument {f.name!r} follows default argument')` in dataclasses.py(466)._init_fn. It happens because dataclass constructor defines all parent class fields as arguments in __init__ class and then all child class fields.
Maybe it need to define all non-default fields in init before all default.

----------
messages: 336297
nosy: Кирилл Чуркин
priority: normal
severity: normal
status: open
title: Inheritance dataclasses fields and default init statement
type: behavior
versions: Python 3.7

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


More information about the Python-bugs-list mailing list