Skip to content

False positive for "no overloads match the provided argument" inside a function #1565

Closed

Description

Describe the bug
I get the no overloads for "fspath" match the provided argument when the code is inside a function but not outside.

To Reproduce
Sample code:

import os
from typing import Union

MyPathLike = Union[str, os.PathLike]

def func(path: MyPathLike) -> None:
    os.fspath(path)

foo: MyPathLike = "foo"

os.fspath(foo)
func(foo)

Expected behavior
No error

Screenshots or Code
Output:

$ pyright
No configuration file found.
stubPath /tmp/pyright5/root/typings is not a valid directory.
Assuming Python platform Linux
Searching for source files
Found 1 source file
/tmp/pyright5/root/src/repro.py
  7:5 - error: No overloads for "fspath" match the provided arguments
    Argument types: (MyPathLike) (reportGeneralTypeIssues)
1 error, 0 warnings, 0 infos
Completed in 0.671sec

Interestingly, Pyright complains about the usage at line 7 (inside the function) but not at line 11, even though they should be equivalent.

VS Code extension or command-line

$ pyright --version                                                                                          1
pyright 1.1.117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions