KotlinIsland / KotlinIsland/basedmypy
infer from overloads doesn't bind type variables
- Dominant language
- Python
- Stars
- 202
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
```py
from typing import overload
from basedtyping import T
@overload
def foo(t: str): ...
@overload
def foo(t: T, b: bool): ...
def foo(t, b=True):
c: T = t # error: Type variable "basedtyping.T" is unbound
```
```py
@overload
def bar[T](t: T): ...
@overload
def bar[T](t: T, b: bool): ...
def bar[T](t, b=True):
c: T = t # error: Name "T" is not defined
```
```py
@overload
def foo[T](t: T) -> T: ...
@overload
def foo[T](t: T, b: bool) -> T: ...
def foo[T](t: T, b=True):
return t # Incompatible return value type (got "T@foo", expected "T@foo | T@foo")
```
Contributor guide
Research direction
Start by reproducing the three overload examples in the issue and trace how overload implementations handle type-variable binding. The issue is resolved when the implementation annotations and generic return value no longer produce unbound, undefined-name, or incompatible-return errors while preserving the overloads' inferred types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100