-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
partial
plugin does not handle overloads
#17585
Comments
an alternative spelling with import functools
from typing import assert_type, overload, TypeVar
T = TypeVar("T", int, str)
def identity(x: T, *, p: str) -> T: return x
p = functools.partial(identity, p='hi')
assert_type(p(1), int)
assert_type(p('hi'), str) $ ./venv/bin/mypy t.py
t.py:10: error: Expression is of type "Any", not "int" [assert-type]
t.py:11: error: Expression is of type "Any", not "str" [assert-type]
Found 2 errors in 1 file (checked 1 source file) |
see python/mypy#17585 <!-- Describe your PR here. -->
see python/mypy#17585 <!-- Describe your PR here. -->
Yes, the behaviour with overloads is unchanged from mypy 1.10. Shouldn't be too bad to add support for it. mypy/mypy/plugins/functools.py Lines 131 to 132 in d1d3c78
The constrained type var example you have is a duplicate of #17411. Note that unconstrained type vars or bounded type vars should work correctly. In general, mypy's handling of constrained type vars is a little weird. |
Bug Report
it appears the new
partial
plugin added in mypy 1.11 doesn't properly handle overloads (and just picks the first one)To Reproduce
Expected Behavior
(no errors)
Actual Behavior
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: