Skip to content

Display of union containing two overloaded functions can inaccurately imply that the union contains duplicate elements #2919

@injust

Description

@injust

Summary

https://play.ty.dev/74e9e34d-7c96-435d-b1fb-1795d4c7c18d

def test(is_upper: bool) -> None:
    converter = str.upper if is_upper else str.lower
    reveal_type(converter)
Revealed type: `(Overload[(self: LiteralString) -> LiteralString, (self) -> str]) | (Overload[(self: LiteralString) -> LiteralString, (self) -> str])` (revealed-type) [Ln 3, Col 17]

The revealed type is a union of (Overload[(self: LiteralString) -> LiteralString, (self) -> str]) twice.

When ty is used as an LSP and type hints are shown as inlay hints, this uses a lot of horizontal space. Whereas basedpyright types this as (self: str) -> str.

Version

d0a231cc9

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions