KotlinIsland / basedtypeshed

Collection of library stubs for Python, with static types
Other
3 stars 0 forks source link

`sorted` should have an overload preserving a union of `list`s #22

Open KotlinIsland opened 2 years ago

KotlinIsland commented 2 years ago
a: list[int] | list[str]
b: list[int] | list[str] = sorted(a)  # error: found list[int | str]

Maybe something like:

L = TypeVar("L", bound=list[SupportsRichComparison])
@overload
def sorted(__iterable: L) -> L: ...

but this is invalid