KotlinIsland / KotlinIsland/basedmypy

generic bounds don't work with syntax generics

Open
#764 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
202
Forks
6
PR merge metrics
No merged PRs in 30d

Description

```py
from typing import TypeVar, Collection

T = TypeVar('T')
L = TypeVar('L', bound=Collection[T])
def foo(l: L) -> T:
return l[0]

reveal_type(foo([1])) # int

def bar[T2, L2: Collection[T2]](l: L2) -> T:
return l[0]

reveal_type(bar([1])) # Never
```

Contributor guide

Open the contributing guide

Research direction

Start by running the two generic examples in the issue and compare their reveal_type results. Trace how traditional TypeVar bounds and syntax generic bounds are handled, then verify that bar([1]) infers int rather than Never and that the existing foo behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.