pyright icon indicating copy to clipboard operation
pyright copied to clipboard

false negative on passing Ps to (*Ps) -> Any

Open pinterior opened this issue 4 years ago • 2 comments

Describe the bug

a buggy program, iterating over Tuple[*Ps] and pass each element to Callable[[*Ps], Any] does not reported as type error by pyright.

To Reproduce

#!/usr/bin/env python3

# pyright: strict

from typing import Any, Callable, Tuple
from typing_extensions import TypeVarTuple, Unpack


Ps = TypeVarTuple("Ps")

def bad_apply(f: Callable[[Unpack[Ps]], Any], p: Tuple[Unpack[Ps]]):
    for i in p:
        f(i)

def f(n: int, s: str = ""):
    print(f"n is {type(n)}")

bad_apply(f, (1, "foo"))
Found 1 source file
pyright 1.1.279
0 errors, 0 warnings, 0 informations

Expected behavior

pyright generates some errors against the code above

VS Code extension or command-line

command-line tool, version 1.1.279

pinterior avatar Nov 12 '22 16:11 pinterior

This will be fixed in the next release.

erictraut avatar Nov 12 '22 19:11 erictraut

This is addressed in pyright 1.1.280, which I just published. It will also be included in a future version of pylance.

erictraut avatar Nov 16 '22 03:11 erictraut