@@ -28,7 +28,6 @@ import { TextRange } from '../common/textRange';
28
28
import { Localizer } from '../localization/localize';
29
29
import {
30
30
ArgumentCategory,
31
- ArrowCallableNode,
32
31
AssignmentNode,
33
32
AugmentedAssignmentNode,
34
33
BinaryOperationNode,
@@ -1071,11 +1070,6 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
1071
1070
break;
1072
1071
}
1073
1072
1074
- case ParseNodeType.ArrowCallable: {
1075
- typeResult = getTypeFromArrowCallable(node, flags);
1076
- break;
1077
- }
1078
-
1079
1073
case ParseNodeType.Assignment: {
1080
1074
typeResult = getTypeOfExpression(node.rightExpression);
1081
1075
assignTypeToExpression(
@@ -11457,136 +11451,6 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
11457
11451
return type;
11458
11452
}
11459
11453
11460
- function getTypeFromArrowCallable(node: ArrowCallableNode, flags: EvaluatorFlags): TypeResult {
11461
- // Emit an error if this will cause a runtime exception.
11462
- const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
11463
- if (
11464
- !fileInfo.isStubFile &&
11465
- fileInfo.executionEnvironment.pythonVersion < PythonVersion.V3_11 &&
11466
- (flags & EvaluatorFlags.NotParsedByInterpreter) === 0
11467
- ) {
11468
- addError(Localizer.Diagnostic.arrowCallableIllegal(), node);
11469
- }
11470
-
11471
- const isIncomplete = false;
11472
- const functionType = FunctionType.createInstantiable('', '', '', FunctionTypeFlags.None);
11473
-
11474
- const enclosingScope = ParseTreeUtils.getEnclosingClassOrFunction(node);
11475
-
11476
- // Handle the case where the Callable has no enclosing scope. This can
11477
- // happen in the case where a generic function return type is annotated
11478
- // with a generic type alias that includes a Callable in its definition.
11479
- functionType.details.typeVarScopeId = enclosingScope
11480
- ? getScopeIdForNode(enclosingScope)
11481
- : WildcardTypeVarScopeId;
11482
-
11483
- const returnAnnotationOptions: AnnotationTypeOptions = {};
11484
- if ((flags & EvaluatorFlags.AssociateTypeVarsWithCurrentScope) !== 0) {
11485
- returnAnnotationOptions.associateTypeVarsWithScope = true;
11486
- }
11487
- if ((flags & EvaluatorFlags.NotParsedByInterpreter) !== 0) {
11488
- returnAnnotationOptions.notParsedByInterpreter = true;
11489
- }
11490
-
11491
- let returnType = getTypeOfAnnotation(node.returnTypeAnnotation, returnAnnotationOptions);
11492
- if (node.isAsync) {
11493
- functionType.details.flags |= FunctionTypeFlags.Async;
11494
- const awaitableType = getTypingType(node, 'Awaitable');
11495
- if (awaitableType && isInstantiableClass(awaitableType)) {
11496
- returnType = ClassType.cloneForSpecialization(
11497
- ClassType.cloneAsInstance(awaitableType),
11498
- [returnType],
11499
- /* isTypeArgumentExplicit */ true
11500
- );
11501
- } else {
11502
- returnType = UnknownType.create();
11503
- }
11504
- }
11505
-
11506
- functionType.details.declaredReturnType = returnType;
11507
-
11508
- let addPositionalOnly = true;
11509
-
11510
- const paramAnnotationOptions: AnnotationTypeOptions = {
11511
- allowParamSpec: true,
11512
- allowTypeVarTuple: true,
11513
- };
11514
-
11515
- if ((flags & EvaluatorFlags.AssociateTypeVarsWithCurrentScope) !== 0) {
11516
- paramAnnotationOptions.associateTypeVarsWithScope = true;
11517
- }
11518
-
11519
- node.parameters.forEach((param, paramIndex) => {
11520
- const paramType = getTypeOfAnnotation(param.typeAnnotation, paramAnnotationOptions);
11521
-
11522
- if (isEllipsisType(paramType)) {
11523
- if (param.category !== ParameterCategory.Simple || paramIndex !== 0 || node.parameters.length > 1) {
11524
- addError(Localizer.Diagnostic.ellipsisContext(), param.typeAnnotation);
11525
- FunctionType.addParameter(functionType, {
11526
- category: ParameterCategory.Simple,
11527
- name: `__p${paramIndex}`,
11528
- isNameSynthesized: true,
11529
- type: UnknownType.create(),
11530
- hasDeclaredType: true,
11531
- });
11532
- } else {
11533
- functionType.details.flags |= FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck;
11534
- FunctionType.addDefaultParameters(functionType);
11535
- addPositionalOnly = false;
11536
- }
11537
- } else if (param.category === ParameterCategory.Simple) {
11538
- if (isTypeVar(paramType) && paramType.details.isParamSpec) {
11539
- addError(Localizer.Diagnostic.arrowCallableParamSpec(), param.typeAnnotation);
11540
- }
11541
-
11542
- if (isTypeVar(paramType) && paramType.details.isVariadic && !paramType.isVariadicUnpacked) {
11543
- addError(Localizer.Diagnostic.arrowCallableVariadicTypeVar(), param.typeAnnotation);
11544
- }
11545
-
11546
- FunctionType.addParameter(functionType, {
11547
- category: ParameterCategory.Simple,
11548
- name: `__p${paramIndex}`,
11549
- isNameSynthesized: true,
11550
- type: convertToInstance(paramType),
11551
- hasDeclaredType: true,
11552
- });
11553
- } else if (param.category === ParameterCategory.VarArgList) {
11554
- if (!isVariadicTypeVar(paramType)) {
11555
- addError(Localizer.Diagnostic.arrowCallableNotVariadicTypeVar(), param.typeAnnotation);
11556
- } else {
11557
- if (paramType.isVariadicUnpacked) {
11558
- addError(Localizer.Diagnostic.arrowCallableVariadicTypeVarUnpacked(), param.typeAnnotation);
11559
- }
11560
-
11561
- FunctionType.addParameter(functionType, {
11562
- category: ParameterCategory.Simple,
11563
- name: `__p${paramIndex}`,
11564
- isNameSynthesized: true,
11565
- type: convertToInstance(TypeVarType.cloneForUnpacked(paramType)),
11566
- hasDeclaredType: true,
11567
- });
11568
- }
11569
- } else if (param.category === ParameterCategory.VarArgDictionary) {
11570
- if (!isParamSpec(paramType)) {
11571
- addError(Localizer.Diagnostic.arrowCallableNotParamSpec(), param.typeAnnotation);
11572
- } else if (paramIndex !== node.parameters.length - 1) {
11573
- addError(Localizer.Diagnostic.arrowCallableParamSpecNotLast(), param.typeAnnotation);
11574
- } else {
11575
- functionType.details.paramSpec = paramType;
11576
- }
11577
- }
11578
- });
11579
-
11580
- if (addPositionalOnly) {
11581
- FunctionType.addParameter(functionType, {
11582
- category: ParameterCategory.Simple,
11583
- type: UnknownType.create(),
11584
- });
11585
- }
11586
-
11587
- return { node, type: functionType, isIncomplete };
11588
- }
11589
-
11590
11454
function getTypeFromDictionary(node: DictionaryNode, expectedType: Type | undefined): TypeResult {
11591
11455
// If the expected type is a union, analyze for each of the subtypes
11592
11456
// to find one that matches.
@@ -16421,8 +16285,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
16421
16285
node.nodeType === ParseNodeType.PatternMapping ||
16422
16286
node.nodeType === ParseNodeType.PatternValue ||
16423
16287
node.nodeType === ParseNodeType.PatternMappingKeyEntry ||
16424
- node.nodeType === ParseNodeType.PatternMappingExpandEntry ||
16425
- node.nodeType === ParseNodeType.ArrowCallable
16288
+ node.nodeType === ParseNodeType.PatternMappingExpandEntry
16426
16289
);
16427
16290
}
16428
16291
0 commit comments