-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Closed as not planned
Copy link
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
Unpacking a dictionary to a parameters list can raise an undesired Too many arguments for ....
call-arg
error when the dictionary is empty. Ignoring the error raises an "Unused "type: ignore" error.
Please see my MWE below.
To Reproduce
from typing import Type
class Abstract:
def __init__(self, one):
pass
class A(Abstract):
pass
class B(Abstract):
def __init__(self, one, two):
pass
MyClass: Type[Abstract]
if 2 + 2 > 4:
MyClass = A
more_kwargs = {}
else:
MyClass = B
more_kwargs = {"two": "two"}
# call-arg: Too many arguments for "Abstract"
my_class = MyClass("one", **more_kwargs)
#mypy(error): Unused "type: ignore" comment
my_class = MyClass("one", **more_kwargs) # type: ignore
Expected Behavior
mypy should see, that we are unpacking nothing into the parameters list and therefore should not raise an error.
Actual Behavior
Unrequired Too many arguments for ....
call-arg
error is raised.
Your Environment
- Mypy version used: 0.950
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini
(and other config files):
[mypy]
python_version = 3.9
exclude = .*py.*env.*
disallow_incomplete_defs = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
show_error_codes = True
warn_unused_configs = True
- Python version used: 3.9.1
- Operating system and version: Windows 10
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong