Do not add kw_only dataclass fields to __match_args__#18892
Conversation
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
There was a problem hiding this comment.
Looks good! Consider also submitting a documentation bug to python/cpython: now the docs fail to mention this rather important aspect (and even seem to suggest the opposite?).
match_args: If true (the default is True), the match_args tuple will be created from the list of parameters to the generated init() method (even if init() is not generated, see above).
kw_only: If true (the default value is False), then all fields will be marked as keyword-only. If a field is marked as keyword-only, then the only effect is that the init() parameter generated from a keyword-only field must be specified with a keyword when init() is called. There is no effect on any other aspect of dataclasses. See the parameter glossary entry for details. Also see the KW_ONLY section.
Agreed, working on it! Thanks! |
In runtime python does not add fields that have
kw_onlymarker:See:
Closes #18863