Closed
Description
Describe the bug
I'm using unittest.mock.patch
in my tests, and it has ability to pass kwargs to configure_mock
later, so i'm using code like this:
from unittest.mock import patch
@patch("urllib.request.urlopen", **{"return_value.status": 200})
def test1(*mocks):
import urllib.request
response = urllib.request.urlopen("https://localhost/")
assert response.status == 200
Starting from pyright 1.1.312
this code throws error: Argument of type "int" cannot be assigned to parameter "create" of type "bool" in function "__call__"
Expected behavior
It works fine.
Code or Screenshots
Here's minimal reproduction with plain function:
from typing import Any
def func(create: bool = False, **kwargs: Any):
...
func(**{"k": 1})
> pyright minimal.py
/home/serg/src/pyright-examples/minimal.py
/home/serg/src/pyright-examples/minimal.py:8:8 - error: Argument of type "int" cannot be assigned to parameter "create" of type "bool" in function "func"
"int" is incompatible with "bool" (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations
VS Code extension or command-line
pyright version 1.1.318 (bug started appearing in 1.1.312)
Additional context
Mypy has the same issue.
> mypy minimal.py
minimal.py:8: error: Argument 1 to "func" has incompatible type "**Dict[str, int]"; expected "bool" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment