Summary
Minimal example:
from pathlib import Path
from typing import reveal_type
foo: list[Path] = [Path("a"), Path("b"), Path("c")]
bar = sorted(foo, key=str)
reveal_type(foo)
reveal_type(sorted)
reveal_type(bar)
For some reason, bar is revealed as list[Path | Buffer] where it should be list[Path]. It does not happen if key=str is omitted, even though also in this case the function generic of the return type depends on the input iterable: (iterable: Iterable[_T@sorted], *, /, key: (_T@sorted, /) -> SupportsDunderLT[Any] | SupportsDunderGT[Any], reverse: bool = False) -> list[_T@sorted]]
Version
ty 0.0.3
Summary
Minimal example:
For some reason, bar is revealed as
list[Path | Buffer]where it should belist[Path]. It does not happen ifkey=stris omitted, even though also in this case the function generic of the return type depends on the input iterable:(iterable: Iterable[_T@sorted], *, /, key: (_T@sorted, /) -> SupportsDunderLT[Any] | SupportsDunderGT[Any], reverse: bool = False) -> list[_T@sorted]]Version
ty 0.0.3