Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statement
Description
Bug Report
When creating a derived class that inherits from two data classes, mypy will immediately flag the derived class with Definition of "__match_args__" in base class "A" is incompatible with definition in base class "B"
To Reproduce
- Create the following file
fromdataclassesimportdataclass@dataclassclassA: prop_a: str@dataclassclassB: prop_b: boolclassDerived(A, B): pass- Run
mypy .and observe the error:
test.py:11: error: Cannot override final attribute "__match_args__" (previously declared in base class "B") test.py:11: error: Cannot override writable attribute "__match_args__" with a final one test.py:11: error: Definition of "__match_args__" in base class "A" is incompatible with definition in base class "B" Found 3 errors in 1 file (checked 1 source file) Expected Behavior
Given that I did not set __match_args__ myself makes this error really hard to understand. I would have expected no such error to occur, especially as the code should work for older Python versions that don't support pattern matching yet.
Your Environment
- Mypy version used: 0.940
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.10
- Operating system and version: Linux, Fedora 35
jakob-keller
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statement