Skip to content

PEP 695 type statements breaks overload collapse #2488

@flying-sheep

Description

@flying-sheep

Summary

https://play.ty.dev/26ba098e-7e20-472d-a2ba-ec5cbfd73e71

I could reduce my example all the way to this.
The evaluate(x, eager=eager) will only typecheck if I remove the “type” from line 5

from typing import overload, Literal

class Eager: ...
class Lazy: ...
type Array = Eager | Lazy  # these work: `Array = …`, `Array: TypeAlias = …`

@overload
def evaluate(x: Eager, /, *, eager: bool = False) -> Eager: ...
@overload
def evaluate(x: Lazy, /, *, eager: Literal[False] = False) -> Lazy: ...
@overload
def evaluate(x: Lazy, /, *, eager: Literal[True]) -> Eager: ...
def evaluate(*args, **kw): ...

def foo(x: Array, *, eager: bool) -> None:
    evaluate(x, eager=eager)

Version

ty 0.0.11 (830cb9c 2026-01-09)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions