KotlinIsland / KotlinIsland/basedmypy

Confusing error using intersection operator (`&`) in value position (eg `TypeVar` bounds)

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

Description

```python
from typing import TypeVar

class Foo: ...
class Bar: ...

T = TypeVar("T", bound=Foo & Bar)
# error: TypeVar "bound" must be a type
# error: Unsupported left operand type for & ("type[Foo]")
```

Something more like "Use quoted types or basedtyping.Intersection".

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the TypeVar example using an intersection expression in the bound value position. Trace where the reported errors are generated and update the diagnostic so it suggests quoted types or basedtyping.Intersection; done when this example produces the clearer guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.