mirror of
https://github.com/microsoft/pyright.git
synced 2024-07-14 11:00:25 +03:00
Fixed bug that resulted in a false negative when assigning to type tuple[Never]
. This addresses #8237.
This commit is contained in:
parent
b5d4d92f0a
commit
427ca1143e
@ -825,9 +825,7 @@ export namespace ClassType {
|
||||
newClassType.includeSubclasses = true;
|
||||
}
|
||||
|
||||
newClassType.tupleTypeArguments = tupleTypeArguments?.map((t) =>
|
||||
isNever(t.type) ? { type: UnknownType.create(), isUnbounded: t.isUnbounded, isOptional: t.isOptional } : t
|
||||
);
|
||||
newClassType.tupleTypeArguments = tupleTypeArguments ? [...tupleTypeArguments] : undefined;
|
||||
|
||||
if (isEmptyContainer !== undefined) {
|
||||
newClassType.isEmptyContainer = isEmptyContainer;
|
||||
|
@ -1,7 +1,8 @@
|
||||
# This sample file tests various aspects of type analysis for tuples.
|
||||
|
||||
import os
|
||||
from typing import Any, Callable
|
||||
from typing import Any, Callable, Never
|
||||
|
||||
from typing_extensions import ( # pyright: ignore[reportMissingModuleSource]
|
||||
TypeVarTuple,
|
||||
Unpack,
|
||||
@ -270,3 +271,13 @@ def func19(a: tuple[int, ...], b: tuple[int, *tuple[int, ...]]):
|
||||
|
||||
# This should generate an error.
|
||||
b5: tuple[int, int, *tuple[int, ...]] = b
|
||||
|
||||
|
||||
def func20(v: tuple[Never]):
|
||||
# This should generate an error.
|
||||
x1: tuple[Never] = (1,)
|
||||
|
||||
# This should generate an error.
|
||||
x2: tuple[Never] = ()
|
||||
|
||||
x3: tuple[Never] = v
|
||||
|
@ -440,7 +440,7 @@ test('Optional2', () => {
|
||||
test('Tuple1', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['tuple1.py']);
|
||||
|
||||
TestUtils.validateResults(analysisResults, 24);
|
||||
TestUtils.validateResults(analysisResults, 26);
|
||||
});
|
||||
|
||||
test('Tuple2', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user