KotlinIsland / KotlinIsland/basedmypy
don't report constrained `TypeVar` with variance if the constraints are assignable
Open
- Dominant language
- Python
- Stars
- 202
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
```py
T1 = TypeVar("T1", object, int, covariant=True) # expect no error
T2 = TypeVar("T2", int, str, covariant=True) # expect error
class A(Generic[T1]):
def get(self) -> T: ...
a_int = A[int]()
a_obj = a_int # valid assignment
```
Contributor guide
Research direction
Start by locating the diagnostic that reports variance on constrained TypeVars and trace how constraint assignability is checked. Add regression coverage for the two TypeVar examples: the object/int constraints should produce no error, while the int/str constraints should still produce an error.
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
- Mostly clear
- Newbie friendliness
- 35/100