[issue39300] dataclasses non-default argument follows default argument

2020-01-10 Thread lijok


lijok  added the comment:

> I think this is a combination of the above statement at end of [0] and 
> inheritance following the order of the fields at [1]

Ah, I see, so if I understand correctly the init method for the example given 
would become __init__(self, PARAM: int = 1, ARG: int) since the fields are kept 
in an ordered mapping

Thank you

--

___
Python tracker 
<https://bugs.python.org/issue39300>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39300] dataclasses non-default argument follows default argument

2020-01-10 Thread lijok


New submission from lijok :

from dataclasses import dataclass


@dataclass
class A:
PARAM: int


@dataclass
class B(A):
ARG: int
PARAM: int = 1

Traceback (most recent call last):
  File "", line 2, in 
  File 
"C:\Users\user\AppData\Local\Programs\Python\Python38\lib\dataclasses.py", line 
1021, in dataclass
return wrap(cls)
  File 
"C:\Users\user\AppData\Local\Programs\Python\Python38\lib\dataclasses.py", line 
1013, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File 
"C:\Users\user\AppData\Local\Programs\Python\Python38\lib\dataclasses.py", line 
927, in _process_class
_init_fn(flds,
  File 
"C:\Users\user\AppData\Local\Programs\Python\Python38\lib\dataclasses.py", line 
503, in _init_fn
raise TypeError(f'non-default argument {f.name!r} '
TypeError: non-default argument 'ARG' follows default argument

--
components: Library (Lib)
messages: 359782
nosy: eric.smith, lijok
priority: normal
severity: normal
status: open
title: dataclasses non-default argument follows default argument
type: behavior
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue39300>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com