Difference with mypy when using manual overloads for TypeVarTuple *args
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
Discussed in https://github.com/microsoft/pyright/discussions/10602
Originally posted by jonaslb June 13, 2025
I have the following example:
from collections.abc import Callable
from typing import overload
class X[CT]:
@overload
def method[T1, Out](
self, x: "X[T1]", /, *, combine: Callable[[CT, T1], Out]
) -> Out: ...
@overload
def method[T1, T2, Out](
self, x: "X[T1]", y: "X[T2]", /, *, combine: Callable[[CT, T1, T2], Out]
) -> Out: ...
def method[*P, Out](
self, *args: "X[object]", combine: Callable[[CT, *P], Out]
) -> Out:
raise NotImplementedError()
Mypy has no issue with it.
Pylance says, on the method implementation, the following:
Overloaded implementation is not consistent with signature of overload 2
Type "(self: Self@X[CT@X], *args: X[object], combine: (CT@X, *P@method) -> Out@method) -> Out@method" is not assignable to type "(self: Self@X[CT@X], x: X[T1@method], y: X[T2@method], /, *, combine: (CT@X, T1@method, T2@method) -> Out@method) -> Out@method"
Keyword parameter "combine" of type "(CT@X, T1@method, T2@method) -> Out@method" is incompatible with type "(CT@X, *P@method) -> Out@method"
Type "(CT@X, T1@method, T2@method) -> Out@method" is not assignable to type "(CT@X, *P@method) -> Out@method"
Position-only parameter mismatch; expected 3 but received 2Pylance[reportInconsistentOverload](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportInconsistentOverload.md)
It seems to me that (CT@X, T1@method, T2@method) should be assignable to (CT@X, *P@method), but I'm not sure if I'm missing something?
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
Start with the minimal Python example in the issue and reproduce the differing results between mypy and Pyright/Pylance. Review the reportInconsistentOverload diagnostic and the linked discussion for context; the issue is done when the behavior is resolved consistently with the intended overload compatibility and covered by an appropriate regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100