-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
featuretopic-inferenceWhen to infer types or require explicit annotationsWhen to infer types or require explicit annotationstopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides
Description
Bug Report
If a subclass __init__ passes **kwargs to it's superclass, the superclasses parameter types should be used to validate the subclass arguments.
To Reproduce
Run mypy on this file:
import datetime
class Bar:
def __init__(self, a: int, b: str, c: datetime.datetime):
pass
class Baz(Bar):
def __init__(self, **kwargs):
super().__init__(**kwargs)
Baz(b=3)Expected Behavior
Something like
error: Argument "b" to "Baz" has incompatible type "int"; expected "str"
Actual Behavior
mypy found no errors
Your Environment
- Mypy version used: mypy 0.800
- Mypy command-line flags: python filename
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.8.6
- Operating system and version: macOS 10.15.7
yogurtandjam, cemlyn007, ikonst, zplizzi, underyx and 10 more
Metadata
Metadata
Assignees
Labels
featuretopic-inferenceWhen to infer types or require explicit annotationsWhen to infer types or require explicit annotationstopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides