mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Fixed recent regression that results in assert_type
failure when a class is parameterized by a ParamSpec with a default value. This addresses #7878.
This commit is contained in:
parent
8a5bfb975c
commit
da446c7c6a
@ -12591,13 +12591,11 @@ export function createTypeEvaluator(
|
||||
}
|
||||
|
||||
function getParamSpecDefaultType(node: ExpressionNode, isPep695Syntax: boolean): Type | undefined {
|
||||
const functionType = FunctionType.createSynthesizedInstance(
|
||||
'',
|
||||
FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck | FunctionTypeFlags.ParamSpecValue
|
||||
);
|
||||
const functionType = FunctionType.createSynthesizedInstance('', FunctionTypeFlags.ParamSpecValue);
|
||||
|
||||
if (node.nodeType === ParseNodeType.Ellipsis) {
|
||||
FunctionType.addDefaultParameters(functionType);
|
||||
functionType.details.flags |= FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck;
|
||||
return functionType;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
# In particular, it tests the handling of default TypeVar types for
|
||||
# generic classes.
|
||||
|
||||
from typing import Generic, Self
|
||||
from typing import Generic, Self, assert_type
|
||||
from typing_extensions import ( # pyright: ignore[reportMissingModuleSource]
|
||||
TypeVar,
|
||||
ParamSpec,
|
||||
@ -117,3 +117,13 @@ reveal_type(
|
||||
ClassD[int, str, [str, complex]],
|
||||
expected_text="type[ClassD[int, str, (str, complex), (bool)]]",
|
||||
)
|
||||
|
||||
P6 = ParamSpec("P6", default=[str, int])
|
||||
|
||||
|
||||
class ClassE(Generic[P6]): ...
|
||||
|
||||
|
||||
assert_type(ClassE, type[ClassE[str, int]])
|
||||
assert_type(ClassE(), ClassE[str, int])
|
||||
assert_type(ClassE[[bool, bool]](), ClassE[bool, bool])
|
||||
|
Loading…
Reference in New Issue
Block a user