Skip to content

ParamSpecs should allow for overload resolution #2642

@superbobry

Description

@superbobry

Describe the Bug

Reproducer:

import atexit
from typing import overload


@overload
def f(x: int) -> None: ...
@overload
def f(x: str, message: str) -> None: ...

def f(x, message=None): ...

atexit.register(f, "foo")

Output:

ERROR Argument `Literal['foo']` is not assignable to parameter `x` with type `int` in function `atexit.register` [bad-argument-type]
  --> /tmp/foo.py:12:20
   |
12 | atexit.register(f, "foo")

It looks like Pyrefly selects the overload too early, before it inspects the arguments passed to atexit.register.

I think the answer to #2355 is "yes" :)

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions