KotlinIsland / KotlinIsland/basedmypy

`list.copy` should return a non-invariant value

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

Description

```py
a = [1, 2, 3]
b: list[object] = a.copy() # error: invariance, expected no error
```

```py
class list[T]:
def copy[R >: T]() -> list[R]: ...
```
(which doesn't exist :()

Contributor guide

Open the contributing guide

Research direction

No implementation file, test, or entry point is named. Reproduce the assignment example and inspect how list.copy() is currently typed; determine a supported way to make the result assignable to list[object]. Done means the example type-checks without an invariance error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.