Skip to content

partial does not select the right overload #3638

Description

@n-gao

Describe the Bug

The following code passes in pyright and ty (ignoring the empty bodies) where the right overload is correctly identified

from typing import Callable, Any, overload
from functools import partial


@overload
def f[C: Callable[..., Any]](x: C) -> C: ...
@overload
def f[C: Callable[..., Any]]() -> Callable[[C], C]: ...
def f[C: Callable[..., Any]](x: C | None = None) -> C | Callable[[C], C]: ...


@partial(f)
def g(x: int) -> str: ...


g(5)

pyrefly fails to correctly identify that the signature of g remained unchanged.

ERROR `int` is not assignable to upper bound `(...) -> Any` of type variable `C` [bad-specialization]
  --> test.py:16:2
   |
16 | g(5)
   |  ^^^
   |
 INFO 1 error

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions