KotlinIsland / KotlinIsland/basedmypy

infer from overloads doesn't bind type variables

Open
#385 0 comments 0 reactions 0 assignees View on GitHub
bug p-1 topic-inference topic-overloads
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.