mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +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.includeSubclasses = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
newClassType.tupleTypeArguments = tupleTypeArguments?.map((t) =>
|
newClassType.tupleTypeArguments = tupleTypeArguments ? [...tupleTypeArguments] : undefined;
|
||||||
isNever(t.type) ? { type: UnknownType.create(), isUnbounded: t.isUnbounded, isOptional: t.isOptional } : t
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isEmptyContainer !== undefined) {
|
if (isEmptyContainer !== undefined) {
|
||||||
newClassType.isEmptyContainer = isEmptyContainer;
|
newClassType.isEmptyContainer = isEmptyContainer;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# This sample file tests various aspects of type analysis for tuples.
|
# This sample file tests various aspects of type analysis for tuples.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable, Never
|
||||||
|
|
||||||
from typing_extensions import ( # pyright: ignore[reportMissingModuleSource]
|
from typing_extensions import ( # pyright: ignore[reportMissingModuleSource]
|
||||||
TypeVarTuple,
|
TypeVarTuple,
|
||||||
Unpack,
|
Unpack,
|
||||||
@ -270,3 +271,13 @@ def func19(a: tuple[int, ...], b: tuple[int, *tuple[int, ...]]):
|
|||||||
|
|
||||||
# This should generate an error.
|
# This should generate an error.
|
||||||
b5: tuple[int, int, *tuple[int, ...]] = b
|
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', () => {
|
test('Tuple1', () => {
|
||||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['tuple1.py']);
|
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['tuple1.py']);
|
||||||
|
|
||||||
TestUtils.validateResults(analysisResults, 24);
|
TestUtils.validateResults(analysisResults, 26);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Tuple2', () => {
|
test('Tuple2', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user