diff --git a/packages/pyright-internal/src/analyzer/typeEvaluator.ts b/packages/pyright-internal/src/analyzer/typeEvaluator.ts index 32fd534779a6..306d577ba437 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluator.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluator.ts @@ -9432,7 +9432,7 @@ export function createTypeEvaluator( // Start by evaluating the types of the arguments without any expected // type. Also, filter the list of overloads based on the number of - // positional and named arguments that are present. We do all of this + // positional and keyword arguments that are present. We do all of this // speculatively because we don't want to record any types in the type // cache or record any diagnostics at this stage. useSpeculativeMode(speculativeNode, () => { @@ -10864,10 +10864,6 @@ export function createTypeEvaluator( errorNode, /* emitNotIterableError */ false )?.type; - - if (paramInfo.param.category !== ParamCategory.ArgsList) { - matchedUnpackedListOfUnknownLength = true; - } } const funcArg: Arg | undefined = listElementType diff --git a/packages/pyright-internal/src/tests/samples/overloadCall5.py b/packages/pyright-internal/src/tests/samples/overloadCall5.py index 9a31718d2429..d7e76f27c192 100644 --- a/packages/pyright-internal/src/tests/samples/overloadCall5.py +++ b/packages/pyright-internal/src/tests/samples/overloadCall5.py @@ -11,22 +11,18 @@ # This should generate an error because this overload overlaps # with the third one and returns a different type. @overload -def func1(__iter1: Iterable[_T1]) -> Tuple[_T1]: - ... +def func1(__iter1: Iterable[_T1]) -> Tuple[_T1]: ... @overload -def func1(__iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> Tuple[_T1, _T2]: - ... +def func1(__iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> Tuple[_T1, _T2]: ... @overload -def func1(*iterables: Iterable[_T1]) -> float: - ... +def func1(*iterables: Iterable[_T1]) -> float: ... -def func1(*iterables: Iterable[_T1 | _T2]) -> Tuple[_T1 | _T2, ...] | float: - ... +def func1(*iterables: Iterable[_T1 | _T2]) -> Tuple[_T1 | _T2, ...] | float: ... def test1(x: Iterable[int]): @@ -48,18 +44,15 @@ def test1(x: Iterable[int]): @overload -def func2() -> tuple[()]: - ... +def func2() -> tuple[()]: ... @overload -def func2(x: int, /) -> tuple[int]: - ... +def func2(x: int, /) -> tuple[int]: ... @overload -def func2(*x: int) -> tuple[int, ...]: - ... +def func2(*x: int) -> tuple[int, ...]: ... def func2(*x: int) -> tuple[int, ...]: @@ -70,3 +63,20 @@ def func2(*x: int) -> tuple[int, ...]: reveal_type(func2(1), expected_text="tuple[int]") reveal_type(func2(1, 2), expected_text="tuple[int, ...]") reveal_type(func2(*[1, 2, 3]), expected_text="tuple[int, ...]") + + +@overload +def func3(x: int, /) -> str: ... + + +@overload +def func3(x: int, y: int, /, *args: int) -> int: ... + + +def func3(*args: int) -> int | str: + return 1 + + +def test3(v: list[int]) -> None: + r = func3(*v) + reveal_type(r, expected_text="int")