зеркало из https://github.com/microsoft/pyright.git
Fixed bug that results in a crash when an empty tuple is used to specialize a generic type alias parameterized by a ParamSpec. This addresses #8694.
This commit is contained in:
Родитель
3d52679f59
Коммит
8c628b0bc4
|
@ -6814,7 +6814,7 @@ export function createTypeEvaluator(
|
|||
typeArgs = [
|
||||
{
|
||||
type: UnknownType.create(),
|
||||
node: typeArgs[0].node,
|
||||
node: typeArgs.length > 0 ? typeArgs[0].node : node,
|
||||
typeList: typeArgs,
|
||||
},
|
||||
];
|
||||
|
|
|
@ -2,8 +2,16 @@
|
|||
# for a generic type alias, a generic function, and a generic class.
|
||||
|
||||
import asyncio
|
||||
from typing import Any, Callable, Concatenate, Coroutine, Generic, ParamSpec, TypeVar
|
||||
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Concatenate,
|
||||
Coroutine,
|
||||
Generic,
|
||||
ParamSpec,
|
||||
TypeAlias,
|
||||
TypeVar,
|
||||
)
|
||||
|
||||
_P = ParamSpec("_P")
|
||||
_R = TypeVar("_R")
|
||||
|
@ -101,3 +109,11 @@ asyncio.run(takes_check_func(my_check_func, 1, "2"))
|
|||
|
||||
# This should generate an error because the signature doesn't match.
|
||||
asyncio.run(takes_check_func(my_check_func, 1, 2))
|
||||
|
||||
|
||||
TA1: TypeAlias = Callable[_P, Any]
|
||||
|
||||
ta1_1: TA1[()] = lambda: 0
|
||||
|
||||
# This should generate an error.
|
||||
ta1_2: TA1[()] = lambda x: x
|
||||
|
|
|
@ -626,7 +626,7 @@ test('ParamSpec12', () => {
|
|||
|
||||
test('ParamSpec13', () => {
|
||||
const results = TestUtils.typeAnalyzeSampleFiles(['paramSpec13.py']);
|
||||
TestUtils.validateResults(results, 6);
|
||||
TestUtils.validateResults(results, 7);
|
||||
});
|
||||
|
||||
test('ParamSpec14', () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче