You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code with overloads with a decorator using a ParamSpec was typechecking fine with mypy 1.6.1 but not with mypy 1.7.0.
To Reproduce
See the following reproducer loosely based on an API client library where I hit this problem.
The library allows optionally parsing the response body into a model class
$ mypy --version
mypy 1.6.1 (compiled: yes)
$ mypy test_overload.py
Success: no issues found in 1 source file
Actual Behavior
It fails to type check:
$ mypy test_overload.py
test_overload.py:33: error: Argument 1 to "handle_exception" has incompatible type"Callable[[type[ResponseT] | None], Coroutine[Any, Any, ResponseT | Response]]"; expected "Callable[[VarArg(Never), KwArg(Never)], Awaitable[Never]]" [arg-type]
test_overload.py:33: error: Overloaded functionimplementation does not accept all possible arguments of signature 1 [misc]
test_overload.py:33: error: Overloaded functionimplementation cannot produce returntype of signature 1 [misc]
test_overload.py:33: error: Overloaded functionimplementation does not accept all possible arguments of signature 2 [misc]
test_overload.py:33: error: Overloaded functionimplementation cannot produce returntype of signature 2 [misc]
Found 5 errors in 1 file (checked 1 source file)
Sync version:
$ python3 -m mypy test_overload_sync.py
test_overload.py:33: error: Argument 1 to "handle_exception" has incompatible type"Callable[[type[ResponseT] | None], ResponseT | Response]"; expected "Callable[[VarArg(Never), KwArg(Never)], Never]" [arg-type]
test_overload.py:33: error: Overloaded functionimplementation does not accept all possible arguments of signature 1 [misc]
test_overload.py:33: error: Overloaded functionimplementation does not accept all possible arguments of signature 2 [misc]
Your Environment
Mypy version used: 1.7.0 (compiled)
Mypy command-line flags: mypy test_overload.py, tried with and without a clean cache
Python version: 3.10.2, 3.11.6
The text was updated successfully, but these errors were encountered:
This is likely a duplicate of #16451. It should be fixed on latest master (merged few minutes ago). Could you please double-check and re-open if needed?
This is likely a duplicate of #16451. It should be fixed on latest master (merged few minutes ago). Could you please double-check and re-open if needed?
Both snippets pass for me locally with the latest master (but not before #16461)
Bug Report
Code with overloads with a decorator using a ParamSpec was typechecking fine with mypy 1.6.1 but not with mypy 1.7.0.
To Reproduce
See the following reproducer loosely based on an API client library where I hit this problem.
The library allows optionally parsing the response body into a model class
test_overload.py
It can be reproduced without async too.
test_overload_sync.py
Expected Behavior
No mypy errors.
This works with 1.6.1:
Actual Behavior
It fails to type check:
Sync version:
Your Environment
The text was updated successfully, but these errors were encountered: