Brandt Bucher <brandtbuc...@gmail.com> added the comment:

> Note that setting compare=False on a dataclass.field already excludes that 
> field from __match_args__...

It appears you did find a genuine bug though! I was surprised by this comment, 
and after digging a bit deeper into _process_class found that we should be 
generating these from "field_list", not "flds":

>>> @dataclass(repr=False, eq=False, init=False)
... class X:
...     a: int
...     b: int
...     c: int
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/home/bucher/src/cpython/Lib/dataclasses.py", line 1042, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File "/home/bucher/src/cpython/Lib/dataclasses.py", line 1020, in 
_process_class
    cls.__match_args__ = tuple(f.name for f in flds if f.init)
UnboundLocalError: local variable 'flds' referenced before assignment

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43764>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to