`partial` plugin does not handle overloads
Open
Nobody has claimed this yet.
bug
topic-overloads
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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
import functools
from typing import assert_type, overload
@overload
def identity(x: int, *, p: str) -> int: ...
@overload
def identity(x: str, *, p: str) -> str: ...
def identity(x: int | str, *, p: str) -> int | str: return x
p = functools.partial(identity, p='hi')
assert_type(p(1), int)
assert_type(p('hi'), str)
Expected Behavior
(no errors)
Actual Behavior
$ mypy t.py
t.py:13: error: Expression is of type "int", not "str" [assert-type]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.11.0
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.12.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided functools.partial, overload, and assert_type example by running mypy t.py. Trace the partial plugin's handling of overloaded callables and add coverage for both int and str arguments. Done means the example reports no errors and preserves both inferred return types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100