Open
Description
Bug report
Bug description:
Right now, dataclasses.dataclass generates a __match_args__ attribute with all the parameters present in the generated __init__ method. I'm not sure that's the right thing to do, given a dataclass could have an InitVar field adding a parameter to the __init__ but not actually creating a field that can be accessed from the dataclass.
In the following example, none of the cases matches:
from dataclasses import dataclass, InitVar
@dataclass
class Foo:
bar: InitVar[int]
baz: str
match Foo(123, 'tst'):
case Foo(bar, baz):
print(bar, baz)
case Foo(baz):
print(baz)The generated __match_args__ is ('bar', 'baz'). I think the correct one should be ('baz',).
CPython versions tested on:
3.11
Operating systems tested on:
Linux