Closed
Description
Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues
I think this is a mypy bug, happy to be sent to typeshed though.
I'm using mypy 0.6, and have the following code:
from unittest import TestCase
from unittest.mock import patch
class A(TestCase):
@patch.dict("os.environ", {"PATH": os.path.expanduser("~/.local/bin")})
@patch.object(moduleA, "a")
@patch("subprocess.check_output")
def test_missing(self, check_output, a):
pass
This errors like so:
error: Too many arguments for "__call__" of "_patch_dict"
The typeshed stub for this is
class _patch_dict:
...
def __init__(self, in_dict: Any, values: Any = ..., clear: Any = ..., **kwargs: Any) -> None: ...
def __call__(self, f: Any) -> Any: ...
...
class _patcher:
TEST_PREFIX = ... # type: str
dict = ... # type: _patch_dict
...
patch = ... # type: _patcher
So mypy should be able to tell that this is instantiating an instance of _patch_dict with __init__
and then that instance is being called with one argument - the curried patcher next inwards in the stack.
Metadata
Metadata
Assignees
Labels
No labels