coc-pyright 1.1.315 → 1.1.316
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1215 -975
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -18646,7 +18646,6 @@ var require_package_nls_en_us = __commonJS({
|
|
|
18646
18646
|
protocolBaseClass: 'Protocol class "{classType}" cannot derive from non-protocol class "{baseType}"',
|
|
18647
18647
|
protocolBaseClassWithTypeArgs: "Type arguments are not allowed with Protocol class when using type parameter syntax",
|
|
18648
18648
|
protocolIllegal: 'Use of "Protocol" requires Python 3.7 or newer',
|
|
18649
|
-
protocolMemberNotClassVar: 'Protocol class "{className}" does not define "{memberName}" as a ClassVar',
|
|
18650
18649
|
protocolNotAllowedInTypeArgument: '"Protocol" cannot be used as a type argument',
|
|
18651
18650
|
protocolUsedInCall: 'Protocol class cannot be used in "{name}" call',
|
|
18652
18651
|
protocolVarianceContravariant: 'Type variable "{variable}" used in generic protocol "{class}" should be contravariant',
|
|
@@ -19549,7 +19548,6 @@ var require_localize = __commonJS({
|
|
|
19549
19548
|
Diagnostic6.protocolBaseClass = () => new ParameterizedString(getRawString("Diagnostic.protocolBaseClass"));
|
|
19550
19549
|
Diagnostic6.protocolBaseClassWithTypeArgs = () => getRawString("Diagnostic.protocolBaseClassWithTypeArgs");
|
|
19551
19550
|
Diagnostic6.protocolIllegal = () => getRawString("Diagnostic.protocolIllegal");
|
|
19552
|
-
Diagnostic6.protocolMemberNotClassVar = () => new ParameterizedString(getRawString("Diagnostic.protocolMemberNotClassVar"));
|
|
19553
19551
|
Diagnostic6.protocolNotAllowedInTypeArgument = () => getRawString("Diagnostic.protocolNotAllowedInTypeArgument");
|
|
19554
19552
|
Diagnostic6.protocolUsedInCall = () => new ParameterizedString(getRawString("Diagnostic.protocolUsedInCall"));
|
|
19555
19553
|
Diagnostic6.protocolVarianceContravariant = () => new ParameterizedString(getRawString("Diagnostic.protocolVarianceContravariant"));
|
|
@@ -28247,7 +28245,7 @@ var require_types = __commonJS({
|
|
|
28247
28245
|
return clone;
|
|
28248
28246
|
}
|
|
28249
28247
|
TypeBase2.cloneType = cloneType;
|
|
28250
|
-
function cloneTypeAsInstance(type) {
|
|
28248
|
+
function cloneTypeAsInstance(type, cache) {
|
|
28251
28249
|
(0, debug_1.assert)(TypeBase2.isInstantiable(type));
|
|
28252
28250
|
const newInstance = TypeBase2.cloneType(type);
|
|
28253
28251
|
if (newInstance.instantiableNestingLevel === void 0) {
|
|
@@ -28261,10 +28259,16 @@ var require_types = __commonJS({
|
|
|
28261
28259
|
newInstance.instantiableNestingLevel--;
|
|
28262
28260
|
}
|
|
28263
28261
|
}
|
|
28262
|
+
if (cache) {
|
|
28263
|
+
if (!type.cached) {
|
|
28264
|
+
type.cached = {};
|
|
28265
|
+
}
|
|
28266
|
+
type.cached.typeBaseInstanceType = newInstance;
|
|
28267
|
+
}
|
|
28264
28268
|
return newInstance;
|
|
28265
28269
|
}
|
|
28266
28270
|
TypeBase2.cloneTypeAsInstance = cloneTypeAsInstance;
|
|
28267
|
-
function cloneTypeAsInstantiable(type) {
|
|
28271
|
+
function cloneTypeAsInstantiable(type, cache) {
|
|
28268
28272
|
const newInstance = TypeBase2.cloneType(type);
|
|
28269
28273
|
if (TypeBase2.isInstance(type)) {
|
|
28270
28274
|
newInstance.flags &= ~2;
|
|
@@ -28272,6 +28276,12 @@ var require_types = __commonJS({
|
|
|
28272
28276
|
} else {
|
|
28273
28277
|
newInstance.instantiableNestingLevel = newInstance.instantiableNestingLevel === void 0 ? 1 : newInstance.instantiableNestingLevel;
|
|
28274
28278
|
}
|
|
28279
|
+
if (cache) {
|
|
28280
|
+
if (!type.cached) {
|
|
28281
|
+
type.cached = {};
|
|
28282
|
+
}
|
|
28283
|
+
type.cached.typeBaseInstantiableType = newInstance;
|
|
28284
|
+
}
|
|
28275
28285
|
return newInstance;
|
|
28276
28286
|
}
|
|
28277
28287
|
TypeBase2.cloneTypeAsInstantiable = cloneTypeAsInstantiable;
|
|
@@ -28437,10 +28447,18 @@ var require_types = __commonJS({
|
|
|
28437
28447
|
}
|
|
28438
28448
|
ClassType2.createInstantiable = createInstantiable;
|
|
28439
28449
|
function cloneAsInstance(type, includeSubclasses = true) {
|
|
28450
|
+
var _a;
|
|
28440
28451
|
if (TypeBase.isInstance(type)) {
|
|
28441
28452
|
return type;
|
|
28442
28453
|
}
|
|
28443
|
-
|
|
28454
|
+
if (includeSubclasses && ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstanceType)) {
|
|
28455
|
+
return type.cached.typeBaseInstanceType;
|
|
28456
|
+
}
|
|
28457
|
+
const newInstance = TypeBase.cloneTypeAsInstance(
|
|
28458
|
+
type,
|
|
28459
|
+
/* cache */
|
|
28460
|
+
includeSubclasses
|
|
28461
|
+
);
|
|
28444
28462
|
newInstance.flags &= ~8;
|
|
28445
28463
|
if (includeSubclasses) {
|
|
28446
28464
|
newInstance.includeSubclasses = true;
|
|
@@ -28448,8 +28466,16 @@ var require_types = __commonJS({
|
|
|
28448
28466
|
return newInstance;
|
|
28449
28467
|
}
|
|
28450
28468
|
ClassType2.cloneAsInstance = cloneAsInstance;
|
|
28451
|
-
function cloneAsInstantiable(
|
|
28452
|
-
|
|
28469
|
+
function cloneAsInstantiable(type) {
|
|
28470
|
+
var _a;
|
|
28471
|
+
if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstantiableType) {
|
|
28472
|
+
return type.cached.typeBaseInstantiableType;
|
|
28473
|
+
}
|
|
28474
|
+
return TypeBase.cloneTypeAsInstantiable(
|
|
28475
|
+
type,
|
|
28476
|
+
/* cache */
|
|
28477
|
+
true
|
|
28478
|
+
);
|
|
28453
28479
|
}
|
|
28454
28480
|
ClassType2.cloneAsInstantiable = cloneAsInstantiable;
|
|
28455
28481
|
function cloneForSpecialization(classType, typeArguments, isTypeArgumentExplicit, includeSubclasses = false, tupleTypeArguments, isEmptyContainer) {
|
|
@@ -28880,7 +28906,7 @@ var require_types = __commonJS({
|
|
|
28880
28906
|
var _a;
|
|
28881
28907
|
const newFunction = create(type.details.name, type.details.fullName, type.details.moduleName, type.details.flags, type.flags, type.details.docString);
|
|
28882
28908
|
newFunction.details = { ...type.details };
|
|
28883
|
-
newFunction.boundToType = boundToType;
|
|
28909
|
+
newFunction.boundToType = boundToType !== null && boundToType !== void 0 ? boundToType : type.boundToType;
|
|
28884
28910
|
newFunction.preBoundFlags = newFunction.details.flags;
|
|
28885
28911
|
if (stripFirstParam) {
|
|
28886
28912
|
if (type.details.parameters.length > 0) {
|
|
@@ -28907,18 +28933,34 @@ var require_types = __commonJS({
|
|
|
28907
28933
|
};
|
|
28908
28934
|
}
|
|
28909
28935
|
newFunction.inferredReturnType = type.inferredReturnType;
|
|
28910
|
-
newFunction.boundTypeVarScopeId = boundTypeVarScopeId;
|
|
28936
|
+
newFunction.boundTypeVarScopeId = boundTypeVarScopeId !== null && boundTypeVarScopeId !== void 0 ? boundTypeVarScopeId : type.boundTypeVarScopeId;
|
|
28911
28937
|
return newFunction;
|
|
28912
28938
|
}
|
|
28913
28939
|
FunctionType2.clone = clone;
|
|
28914
28940
|
function cloneAsInstance(type) {
|
|
28915
|
-
|
|
28941
|
+
var _a;
|
|
28942
|
+
if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstanceType) {
|
|
28943
|
+
return type.cached.typeBaseInstanceType;
|
|
28944
|
+
}
|
|
28945
|
+
const newInstance = TypeBase.cloneTypeAsInstance(
|
|
28946
|
+
type,
|
|
28947
|
+
/* cache */
|
|
28948
|
+
true
|
|
28949
|
+
);
|
|
28916
28950
|
newInstance.flags &= ~8;
|
|
28917
28951
|
return newInstance;
|
|
28918
28952
|
}
|
|
28919
28953
|
FunctionType2.cloneAsInstance = cloneAsInstance;
|
|
28920
28954
|
function cloneAsInstantiable(type) {
|
|
28921
|
-
|
|
28955
|
+
var _a;
|
|
28956
|
+
if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstantiableType) {
|
|
28957
|
+
return type.cached.typeBaseInstantiableType;
|
|
28958
|
+
}
|
|
28959
|
+
const newInstance = TypeBase.cloneTypeAsInstantiable(
|
|
28960
|
+
type,
|
|
28961
|
+
/* cache */
|
|
28962
|
+
true
|
|
28963
|
+
);
|
|
28922
28964
|
newInstance.flags &= ~8;
|
|
28923
28965
|
return newInstance;
|
|
28924
28966
|
}
|
|
@@ -29469,14 +29511,30 @@ var require_types = __commonJS({
|
|
|
29469
29511
|
}
|
|
29470
29512
|
TypeVarType2.createInstantiable = createInstantiable;
|
|
29471
29513
|
function cloneAsInstance(type) {
|
|
29514
|
+
var _a;
|
|
29472
29515
|
(0, debug_1.assert)(TypeBase.isInstantiable(type));
|
|
29473
|
-
|
|
29516
|
+
if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstanceType) {
|
|
29517
|
+
return type.cached.typeBaseInstanceType;
|
|
29518
|
+
}
|
|
29519
|
+
const newInstance = TypeBase.cloneTypeAsInstance(
|
|
29520
|
+
type,
|
|
29521
|
+
/* cache */
|
|
29522
|
+
true
|
|
29523
|
+
);
|
|
29474
29524
|
newInstance.flags &= ~8;
|
|
29475
29525
|
return newInstance;
|
|
29476
29526
|
}
|
|
29477
29527
|
TypeVarType2.cloneAsInstance = cloneAsInstance;
|
|
29478
29528
|
function cloneAsInstantiable(type) {
|
|
29479
|
-
|
|
29529
|
+
var _a;
|
|
29530
|
+
if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstantiableType) {
|
|
29531
|
+
return type.cached.typeBaseInstantiableType;
|
|
29532
|
+
}
|
|
29533
|
+
const newInstance = TypeBase.cloneTypeAsInstantiable(
|
|
29534
|
+
type,
|
|
29535
|
+
/* cache */
|
|
29536
|
+
true
|
|
29537
|
+
);
|
|
29480
29538
|
newInstance.flags &= ~8;
|
|
29481
29539
|
return newInstance;
|
|
29482
29540
|
}
|
|
@@ -30675,8 +30733,8 @@ var require_typeUtils = __commonJS({
|
|
|
30675
30733
|
"node_modules/@zzzen/pyright-internal/dist/analyzer/typeUtils.js"(exports) {
|
|
30676
30734
|
"use strict";
|
|
30677
30735
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30678
|
-
exports.
|
|
30679
|
-
exports.convertParamSpecValueToType = exports.convertTypeToParamSpecValue = exports.getDeclaringModulesForType = exports.computeMroLinearization = exports.isVarianceOfTypeArgumentCompatible = exports.combineVariances = exports.requiresSpecialization = exports.requiresTypeArguments = exports.getGeneratorTypeArgs = exports.removeParamSpecVariadicsFromFunction = exports.removeParamSpecVariadicsFromSignature = exports.specializeTupleClass = exports.combineSameSizedTuples = exports.explodeGenericClass = exports.isPartlyUnknown = exports.containsAnyOrUnknown = exports.getMembersForModule = exports.getMembersForClass = exports.convertToInstantiable = exports.convertToInstance = exports.isEffectivelyInstantiable = exports.isMetaclassInstance = exports.isInstantiableMetaclass = exports.getGeneratorYieldType = exports.getDeclaredGeneratorReturnType = exports.synthesizeTypeVarForSelfCls = exports.derivesFromClassRecursive = exports.specializeForBaseClass = exports.buildTypeVarContext = exports.buildTypeVarContextFromSpecializedClass = exports.setTypeArgumentsRecursive = exports.specializeClassType = exports.isTypeVarLimitedToCallable = exports.getTypeVarArgumentsRecursive = exports.addTypeVarsToListIfUnique = exports.getClassFieldsRecursive = exports.getClassIterator = exports.getClassMemberIterator = void 0;
|
|
30736
|
+
exports.lookUpObjectMember = exports.getContainerDepth = exports.getProtocolSymbolsRecursive = exports.getProtocolSymbols = exports.transformExpectedType = exports.validateTypeVarDefault = exports.applyInScopePlaceholders = exports.applySourceContextTypeVarsToSignature = exports.applySourceContextTypeVars = exports.applySolvedTypeVars = exports.ensureFunctionSignaturesAreUnique = exports.populateTypeVarContextForSelfType = exports.partiallySpecializeType = exports.isUnboundedTupleClass = exports.isTupleClass = exports.isMaybeDescriptorInstance = exports.isDescriptorInstance = exports.isCallableType = exports.isProperty = exports.isEllipsisType = exports.getUnionSubtypeCount = exports.getLiteralTypeClassName = exports.containsLiteralType = exports.isLiteralTypeOrUnion = exports.isLiteralType = exports.getSpecializedTupleType = exports.specializeWithDefaultTypeArgs = exports.getTypeVarScopeIds = exports.getTypeVarScopeId = exports.transformPossibleRecursiveTypeAlias = exports.isTypeAliasRecursive = exports.isTypeAliasPlaceholder = exports.getTypeCondition = exports.addConditionToType = exports.getFullNameOfType = exports.derivesFromAnyOrUnknown = exports.isUnionableType = exports.preserveUnknown = exports.areTypesSame = exports.doForEachSubtype = exports.sortTypes = exports.mapSubtypes = exports.makeInferenceContext = exports.isTypeVarSame = exports.isIncompleteUnknown = exports.isOptionalType = exports.UniqueSignatureTracker = exports.AssignTypeFlags = exports.ClassIteratorFlags = exports.ClassMemberLookupFlags = void 0;
|
|
30737
|
+
exports.convertParamSpecValueToType = exports.convertTypeToParamSpecValue = exports.getDeclaringModulesForType = exports.computeMroLinearization = exports.isVarianceOfTypeArgumentCompatible = exports.combineVariances = exports.requiresSpecialization = exports.requiresTypeArguments = exports.getGeneratorTypeArgs = exports.removeParamSpecVariadicsFromFunction = exports.removeParamSpecVariadicsFromSignature = exports.specializeTupleClass = exports.combineSameSizedTuples = exports.explodeGenericClass = exports.isPartlyUnknown = exports.containsAnyOrUnknown = exports.getMembersForModule = exports.getMembersForClass = exports.convertToInstantiable = exports.convertToInstance = exports.isEffectivelyInstantiable = exports.isMetaclassInstance = exports.isInstantiableMetaclass = exports.getGeneratorYieldType = exports.getDeclaredGeneratorReturnType = exports.synthesizeTypeVarForSelfCls = exports.derivesFromClassRecursive = exports.specializeForBaseClass = exports.buildTypeVarContext = exports.buildTypeVarContextFromSpecializedClass = exports.setTypeArgumentsRecursive = exports.specializeClassType = exports.isTypeVarLimitedToCallable = exports.getTypeVarArgumentsRecursive = exports.addTypeVarsToListIfUnique = exports.getClassFieldsRecursive = exports.getClassIterator = exports.getClassMemberIterator = exports.lookUpClassMember = void 0;
|
|
30680
30738
|
var collectionUtils_1 = require_collectionUtils();
|
|
30681
30739
|
var debug_1 = require_debug2();
|
|
30682
30740
|
var symbol_1 = require_symbol();
|
|
@@ -30715,6 +30773,7 @@ var require_typeUtils = __commonJS({
|
|
|
30715
30773
|
AssignTypeFlags2[AssignTypeFlags2["SkipSelfClsTypeCheck"] = 256] = "SkipSelfClsTypeCheck";
|
|
30716
30774
|
AssignTypeFlags2[AssignTypeFlags2["IgnoreTypeVarScope"] = 512] = "IgnoreTypeVarScope";
|
|
30717
30775
|
AssignTypeFlags2[AssignTypeFlags2["PopulatingExpectedType"] = 1024] = "PopulatingExpectedType";
|
|
30776
|
+
AssignTypeFlags2[AssignTypeFlags2["AllowUnspecifiedTypeArguments"] = 2048] = "AllowUnspecifiedTypeArguments";
|
|
30718
30777
|
})(AssignTypeFlags = exports.AssignTypeFlags || (exports.AssignTypeFlags = {}));
|
|
30719
30778
|
var UniqueSignatureTracker = class {
|
|
30720
30779
|
constructor() {
|
|
@@ -31099,20 +31158,38 @@ var require_typeUtils = __commonJS({
|
|
|
31099
31158
|
}
|
|
31100
31159
|
exports.getTypeVarScopeId = getTypeVarScopeId;
|
|
31101
31160
|
function getTypeVarScopeIds(type) {
|
|
31161
|
+
const scopeIds = [];
|
|
31102
31162
|
const scopeId = getTypeVarScopeId(type);
|
|
31103
|
-
if (scopeId
|
|
31104
|
-
|
|
31163
|
+
if (scopeId) {
|
|
31164
|
+
scopeIds.push(scopeId);
|
|
31165
|
+
}
|
|
31166
|
+
if ((0, types_1.isFunction)(type)) {
|
|
31105
31167
|
if (type.details.constructorTypeVarScopeId) {
|
|
31106
31168
|
scopeIds.push(type.details.constructorTypeVarScopeId);
|
|
31107
31169
|
}
|
|
31108
31170
|
if (type.details.paramSpecTypeVarScopeId) {
|
|
31109
31171
|
scopeIds.push(type.details.paramSpecTypeVarScopeId);
|
|
31110
31172
|
}
|
|
31111
|
-
return scopeIds;
|
|
31112
31173
|
}
|
|
31113
|
-
return
|
|
31174
|
+
return scopeIds;
|
|
31114
31175
|
}
|
|
31115
31176
|
exports.getTypeVarScopeIds = getTypeVarScopeIds;
|
|
31177
|
+
function specializeWithDefaultTypeArgs(type) {
|
|
31178
|
+
if (type.details.typeParameters.length === 0 || type.typeArguments) {
|
|
31179
|
+
return type;
|
|
31180
|
+
}
|
|
31181
|
+
return types_1.ClassType.cloneForSpecialization(
|
|
31182
|
+
type,
|
|
31183
|
+
type.details.typeParameters.map((param) => {
|
|
31184
|
+
var _a;
|
|
31185
|
+
return (_a = param.details.defaultType) !== null && _a !== void 0 ? _a : types_1.UnknownType.create();
|
|
31186
|
+
}),
|
|
31187
|
+
/* isTypeArgumentExplicit */
|
|
31188
|
+
false,
|
|
31189
|
+
!!type.includeSubclasses
|
|
31190
|
+
);
|
|
31191
|
+
}
|
|
31192
|
+
exports.specializeWithDefaultTypeArgs = specializeWithDefaultTypeArgs;
|
|
31116
31193
|
function getSpecializedTupleType(type) {
|
|
31117
31194
|
let classType;
|
|
31118
31195
|
if ((0, types_1.isInstantiableClass)(type)) {
|
|
@@ -32041,10 +32118,12 @@ var require_typeUtils = __commonJS({
|
|
|
32041
32118
|
if (type.typeAliasInfo && type !== result) {
|
|
32042
32119
|
result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
|
32043
32120
|
}
|
|
32044
|
-
if (
|
|
32045
|
-
type.cached
|
|
32121
|
+
if (type !== result) {
|
|
32122
|
+
if (!type.cached) {
|
|
32123
|
+
type.cached = {};
|
|
32124
|
+
}
|
|
32125
|
+
type.cached.instantiableType = result;
|
|
32046
32126
|
}
|
|
32047
|
-
type.cached.instantiableType = result;
|
|
32048
32127
|
return result;
|
|
32049
32128
|
}
|
|
32050
32129
|
exports.convertToInstantiable = convertToInstantiable;
|
|
@@ -40538,6 +40617,7 @@ var require_parameterUtils = __commonJS({
|
|
|
40538
40617
|
}, index, specializedParamType);
|
|
40539
40618
|
});
|
|
40540
40619
|
result.hasUnpackedTypedDict = true;
|
|
40620
|
+
result.unpackedKwargsTypedDictType = paramType;
|
|
40541
40621
|
} else if (param.name) {
|
|
40542
40622
|
if (result.kwargsIndex === void 0) {
|
|
40543
40623
|
result.kwargsIndex = result.params.length;
|
|
@@ -40583,7 +40663,7 @@ var require_typeEvaluatorTypes = __commonJS({
|
|
|
40583
40663
|
EvaluatorFlags2[EvaluatorFlags2["DisallowFinal"] = 16] = "DisallowFinal";
|
|
40584
40664
|
EvaluatorFlags2[EvaluatorFlags2["DisallowParamSpec"] = 32] = "DisallowParamSpec";
|
|
40585
40665
|
EvaluatorFlags2[EvaluatorFlags2["DisallowTypeVarTuple"] = 64] = "DisallowTypeVarTuple";
|
|
40586
|
-
EvaluatorFlags2[EvaluatorFlags2["
|
|
40666
|
+
EvaluatorFlags2[EvaluatorFlags2["ExpectingInstantiableType"] = 128] = "ExpectingInstantiableType";
|
|
40587
40667
|
EvaluatorFlags2[EvaluatorFlags2["ExpectingTypeAnnotation"] = 256] = "ExpectingTypeAnnotation";
|
|
40588
40668
|
EvaluatorFlags2[EvaluatorFlags2["AllowMissingTypeArgs"] = 512] = "AllowMissingTypeArgs";
|
|
40589
40669
|
EvaluatorFlags2[EvaluatorFlags2["AllowGenericClassType"] = 1024] = "AllowGenericClassType";
|
|
@@ -40858,6 +40938,11 @@ var require_constraintSolver = __commonJS({
|
|
|
40858
40938
|
let newWideTypeBound = curWideTypeBound;
|
|
40859
40939
|
const diagAddendum = diag ? new diagnostic_1.DiagnosticAddendum() : void 0;
|
|
40860
40940
|
let adjSrcType = srcType;
|
|
40941
|
+
if ((flags & 2048) === 0) {
|
|
40942
|
+
if ((0, types_1.isClass)(adjSrcType) && adjSrcType.includeSubclasses) {
|
|
40943
|
+
adjSrcType = (0, typeUtils_1.specializeWithDefaultTypeArgs)(adjSrcType);
|
|
40944
|
+
}
|
|
40945
|
+
}
|
|
40861
40946
|
if (types_1.TypeBase.isInstantiable(destType)) {
|
|
40862
40947
|
if ((0, typeUtils_1.isEffectivelyInstantiable)(adjSrcType)) {
|
|
40863
40948
|
adjSrcType = (0, typeUtils_1.convertToInstance)(
|
|
@@ -41293,6 +41378,10 @@ var require_constraintSolver = __commonJS({
|
|
|
41293
41378
|
}
|
|
41294
41379
|
if (typeArgValue) {
|
|
41295
41380
|
const variance = types_1.TypeVarType.getVariance(typeVar);
|
|
41381
|
+
if (typeVarContext.getPrimarySignature().getTypeVarType(targetTypeVar)) {
|
|
41382
|
+
isResultValid = false;
|
|
41383
|
+
typeArgValue = types_1.UnknownType.create();
|
|
41384
|
+
}
|
|
41296
41385
|
typeVarContext.setTypeVarType(
|
|
41297
41386
|
targetTypeVar,
|
|
41298
41387
|
variance === 3 ? void 0 : typeArgValue,
|
|
@@ -41666,14 +41755,14 @@ var require_typedDicts = __commonJS({
|
|
|
41666
41755
|
let returnType;
|
|
41667
41756
|
if (isEntryRequired) {
|
|
41668
41757
|
defaultParamType = types_1.AnyType.create();
|
|
41669
|
-
returnType = valueType
|
|
41758
|
+
returnType = valueType;
|
|
41670
41759
|
} else {
|
|
41671
|
-
|
|
41672
|
-
|
|
41673
|
-
returnType = defaultTypeMatchesField ? valueType : (0, types_1.combineTypes)([valueType, defaultTypeVar]);
|
|
41760
|
+
if (defaultTypeMatchesField) {
|
|
41761
|
+
defaultParamType = valueType;
|
|
41674
41762
|
} else {
|
|
41675
|
-
|
|
41763
|
+
defaultParamType = (0, types_1.combineTypes)([valueType, defaultTypeVar]);
|
|
41676
41764
|
}
|
|
41765
|
+
returnType = defaultParamType;
|
|
41677
41766
|
}
|
|
41678
41767
|
types_1.FunctionType.addParameter(getOverload, {
|
|
41679
41768
|
category: 0,
|
|
@@ -41683,7 +41772,7 @@ var require_typedDicts = __commonJS({
|
|
|
41683
41772
|
});
|
|
41684
41773
|
getOverload.details.declaredReturnType = returnType;
|
|
41685
41774
|
} else {
|
|
41686
|
-
getOverload.details.declaredReturnType = isEntryRequired ? valueType : (0, types_1.combineTypes)([valueType
|
|
41775
|
+
getOverload.details.declaredReturnType = isEntryRequired ? valueType : (0, types_1.combineTypes)([valueType, types_1.NoneType.createInstance()]);
|
|
41687
41776
|
}
|
|
41688
41777
|
return getOverload;
|
|
41689
41778
|
}, createPopMethods = function(keyType, valueType) {
|
|
@@ -41802,16 +41891,6 @@ var require_typedDicts = __commonJS({
|
|
|
41802
41891
|
true
|
|
41803
41892
|
));
|
|
41804
41893
|
} else {
|
|
41805
|
-
getOverloads.push(createGetMethod(
|
|
41806
|
-
nameLiteralType,
|
|
41807
|
-
entry.valueType,
|
|
41808
|
-
/* includeDefault */
|
|
41809
|
-
true,
|
|
41810
|
-
/* isEntryRequired */
|
|
41811
|
-
false,
|
|
41812
|
-
/* defaultTypeMatchesField */
|
|
41813
|
-
true
|
|
41814
|
-
));
|
|
41815
41894
|
getOverloads.push(createGetMethod(
|
|
41816
41895
|
nameLiteralType,
|
|
41817
41896
|
entry.valueType,
|
|
@@ -41845,7 +41924,7 @@ var require_typedDicts = __commonJS({
|
|
|
41845
41924
|
getOverloads.push(createGetMethod(
|
|
41846
41925
|
literalStringInstance,
|
|
41847
41926
|
/* valueType */
|
|
41848
|
-
|
|
41927
|
+
types_1.UnknownType.create(),
|
|
41849
41928
|
/* includeDefault */
|
|
41850
41929
|
true
|
|
41851
41930
|
));
|
|
@@ -42710,7 +42789,7 @@ var require_typeGuards = __commonJS({
|
|
|
42710
42789
|
const isInstanceCheck = callType.details.builtInName === "isinstance";
|
|
42711
42790
|
const arg1TypeResult = evaluator.getTypeOfExpression(
|
|
42712
42791
|
arg1Expr,
|
|
42713
|
-
8 | 32 | 64
|
|
42792
|
+
512 | 8 | 32 | 64
|
|
42714
42793
|
/* DisallowTypeVarTuple */
|
|
42715
42794
|
);
|
|
42716
42795
|
const arg1Type = arg1TypeResult.type;
|
|
@@ -43134,31 +43213,33 @@ var require_typeGuards = __commonJS({
|
|
|
43134
43213
|
if (filterIsSuperclass) {
|
|
43135
43214
|
filteredTypes.push((0, typeUtils_1.addConditionToType)(varType, constraints));
|
|
43136
43215
|
} else if (filterIsSubclass) {
|
|
43137
|
-
|
|
43138
|
-
|
|
43139
|
-
if (types_1.
|
|
43140
|
-
|
|
43141
|
-
|
|
43142
|
-
|
|
43143
|
-
|
|
43144
|
-
|
|
43145
|
-
|
|
43146
|
-
|
|
43147
|
-
|
|
43148
|
-
|
|
43149
|
-
|
|
43150
|
-
|
|
43151
|
-
|
|
43152
|
-
|
|
43153
|
-
|
|
43154
|
-
|
|
43155
|
-
|
|
43156
|
-
|
|
43157
|
-
|
|
43216
|
+
if (evaluator.assignType(varType, filterType)) {
|
|
43217
|
+
let specializedFilterType = filterType;
|
|
43218
|
+
if ((0, types_1.isClass)(filterType)) {
|
|
43219
|
+
if (types_1.ClassType.isSpecialBuiltIn(filterType) || filterType.details.typeParameters.length > 0) {
|
|
43220
|
+
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(filterType));
|
|
43221
|
+
const unspecializedFilterType = types_1.ClassType.cloneForSpecialization(
|
|
43222
|
+
filterType,
|
|
43223
|
+
/* typeArguments */
|
|
43224
|
+
void 0,
|
|
43225
|
+
/* isTypeArgumentExplicit */
|
|
43226
|
+
false
|
|
43227
|
+
);
|
|
43228
|
+
if ((0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(
|
|
43229
|
+
evaluator,
|
|
43230
|
+
unspecializedFilterType,
|
|
43231
|
+
varType,
|
|
43232
|
+
typeVarContext,
|
|
43233
|
+
/* liveTypeVarScopes */
|
|
43234
|
+
void 0,
|
|
43235
|
+
errorNode.start
|
|
43236
|
+
)) {
|
|
43237
|
+
specializedFilterType = (0, typeUtils_1.applySolvedTypeVars)(unspecializedFilterType, typeVarContext, { unknownIfNotFound: true });
|
|
43238
|
+
}
|
|
43158
43239
|
}
|
|
43159
43240
|
}
|
|
43241
|
+
filteredTypes.push((0, typeUtils_1.addConditionToType)(specializedFilterType, constraints));
|
|
43160
43242
|
}
|
|
43161
|
-
filteredTypes.push((0, typeUtils_1.addConditionToType)(specializedFilterType, constraints));
|
|
43162
43243
|
} else if (allowIntersections && !types_1.ClassType.isFinal(varType) && !types_1.ClassType.isFinal(concreteFilterType)) {
|
|
43163
43244
|
const className = `<subclass of ${varType.details.name} and ${concreteFilterType.details.name}>`;
|
|
43164
43245
|
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
|
@@ -45020,7 +45101,7 @@ var require_codeFlowUtils = __commonJS({
|
|
|
45020
45101
|
if (f.flags & (codeFlowTypes_1.FlowFlags.LoopLabel | codeFlowTypes_1.FlowFlags.BranchLabel)) {
|
|
45021
45102
|
return f.antecedents;
|
|
45022
45103
|
}
|
|
45023
|
-
if (f.flags & (codeFlowTypes_1.FlowFlags.Assignment | codeFlowTypes_1.FlowFlags.VariableAnnotation | codeFlowTypes_1.FlowFlags.WildcardImport | codeFlowTypes_1.FlowFlags.TrueCondition | codeFlowTypes_1.FlowFlags.FalseCondition | codeFlowTypes_1.FlowFlags.NarrowForPattern | codeFlowTypes_1.FlowFlags.ExhaustedMatch | codeFlowTypes_1.FlowFlags.Call | codeFlowTypes_1.FlowFlags.PreFinallyGate | codeFlowTypes_1.FlowFlags.PostFinally)) {
|
|
45104
|
+
if (f.flags & (codeFlowTypes_1.FlowFlags.Assignment | codeFlowTypes_1.FlowFlags.VariableAnnotation | codeFlowTypes_1.FlowFlags.WildcardImport | codeFlowTypes_1.FlowFlags.TrueCondition | codeFlowTypes_1.FlowFlags.FalseCondition | codeFlowTypes_1.FlowFlags.TrueNeverCondition | codeFlowTypes_1.FlowFlags.FalseNeverCondition | codeFlowTypes_1.FlowFlags.NarrowForPattern | codeFlowTypes_1.FlowFlags.ExhaustedMatch | codeFlowTypes_1.FlowFlags.Call | codeFlowTypes_1.FlowFlags.PreFinallyGate | codeFlowTypes_1.FlowFlags.PostFinally)) {
|
|
45024
45105
|
const typedFlowNode = f;
|
|
45025
45106
|
return [typedFlowNode.antecedent];
|
|
45026
45107
|
}
|
|
@@ -45819,19 +45900,27 @@ var require_codeFlowEngine = __commonJS({
|
|
|
45819
45900
|
let sawPending = false;
|
|
45820
45901
|
let isProvenReachable = reference === void 0 && ((_a = cacheEntry.incompleteSubtypes) === null || _a === void 0 ? void 0 : _a.some((subtype) => subtype.type !== void 0));
|
|
45821
45902
|
let firstAntecedentTypeIsIncomplete = false;
|
|
45903
|
+
let firstAntecedentTypeIsPending = false;
|
|
45822
45904
|
loopNode.antecedents.forEach((antecedent, index) => {
|
|
45823
45905
|
var _a2, _b;
|
|
45824
45906
|
if (reference === void 0 && isProvenReachable) {
|
|
45825
45907
|
return;
|
|
45826
45908
|
}
|
|
45909
|
+
if (firstAntecedentTypeIsPending && index > 0) {
|
|
45910
|
+
return;
|
|
45911
|
+
}
|
|
45827
45912
|
cacheEntry = getCacheEntry(loopNode);
|
|
45828
45913
|
if (cacheEntry.incompleteSubtypes && index < cacheEntry.incompleteSubtypes.length && cacheEntry.incompleteSubtypes[index].isPending) {
|
|
45829
|
-
|
|
45830
|
-
|
|
45831
|
-
|
|
45914
|
+
if (index === 0) {
|
|
45915
|
+
firstAntecedentTypeIsPending = true;
|
|
45916
|
+
} else {
|
|
45917
|
+
sawIncomplete = true;
|
|
45918
|
+
sawPending = true;
|
|
45919
|
+
return;
|
|
45920
|
+
}
|
|
45832
45921
|
}
|
|
45833
45922
|
const subtypeEntry = cacheEntry.incompleteSubtypes !== void 0 && index < cacheEntry.incompleteSubtypes.length ? cacheEntry.incompleteSubtypes[index] : void 0;
|
|
45834
|
-
if (subtypeEntry === void 0 || !(subtypeEntry === null || subtypeEntry === void 0 ? void 0 : subtypeEntry.isPending) && (subtypeEntry === null || subtypeEntry === void 0 ? void 0 : subtypeEntry.isIncomplete)) {
|
|
45923
|
+
if (subtypeEntry === void 0 || !(subtypeEntry === null || subtypeEntry === void 0 ? void 0 : subtypeEntry.isPending) && (subtypeEntry === null || subtypeEntry === void 0 ? void 0 : subtypeEntry.isIncomplete) || index === 0) {
|
|
45835
45924
|
const entryEvaluationCount = subtypeEntry === void 0 ? 0 : subtypeEntry.evaluationCount;
|
|
45836
45925
|
cacheEntry = setIncompleteSubtype(
|
|
45837
45926
|
loopNode,
|
|
@@ -45910,6 +45999,9 @@ var require_codeFlowEngine = __commonJS({
|
|
|
45910
45999
|
if (sawPending || sawIncomplete) {
|
|
45911
46000
|
return { type: effectiveType, isIncomplete: reportIncomplete };
|
|
45912
46001
|
}
|
|
46002
|
+
if (firstAntecedentTypeIsPending) {
|
|
46003
|
+
return { type: effectiveType, isIncomplete: true };
|
|
46004
|
+
}
|
|
45913
46005
|
return setCacheEntry(
|
|
45914
46006
|
loopNode,
|
|
45915
46007
|
effectiveType,
|
|
@@ -47070,9 +47162,7 @@ var require_constructors = __commonJS({
|
|
|
47070
47162
|
/* SkipObjectBaseClass */
|
|
47071
47163
|
);
|
|
47072
47164
|
if (initInfo) {
|
|
47073
|
-
|
|
47074
|
-
const objectType = types_1.ClassType.cloneAsInstance(classType);
|
|
47075
|
-
const convertInitToConstructor = (initSubtype) => {
|
|
47165
|
+
let convertInitToConstructor = function(initSubtype) {
|
|
47076
47166
|
let constructorFunction2 = evaluator.bindFunctionToClassOrObject(
|
|
47077
47167
|
objectType,
|
|
47078
47168
|
initSubtype,
|
|
@@ -47085,6 +47175,7 @@ var require_constructors = __commonJS({
|
|
|
47085
47175
|
if (constructorFunction2) {
|
|
47086
47176
|
constructorFunction2 = types_1.FunctionType.clone(constructorFunction2);
|
|
47087
47177
|
constructorFunction2.details.declaredReturnType = objectType;
|
|
47178
|
+
constructorFunction2.details.typeVarScopeId = initSubtype.details.typeVarScopeId;
|
|
47088
47179
|
if (constructorFunction2.specializedTypes) {
|
|
47089
47180
|
constructorFunction2.specializedTypes.returnType = objectType;
|
|
47090
47181
|
}
|
|
@@ -47092,9 +47183,12 @@ var require_constructors = __commonJS({
|
|
|
47092
47183
|
constructorFunction2.details.docString = classType.details.docString;
|
|
47093
47184
|
}
|
|
47094
47185
|
constructorFunction2.details.flags &= ~4;
|
|
47186
|
+
constructorFunction2.details.constructorTypeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(classType);
|
|
47095
47187
|
}
|
|
47096
47188
|
return constructorFunction2;
|
|
47097
47189
|
};
|
|
47190
|
+
const initType = evaluator.getTypeOfMember(initInfo);
|
|
47191
|
+
const objectType = types_1.ClassType.cloneAsInstance(classType);
|
|
47098
47192
|
if ((0, types_1.isFunction)(initType)) {
|
|
47099
47193
|
return convertInitToConstructor(initType);
|
|
47100
47194
|
} else if ((0, types_1.isOverloadedFunction)(initType)) {
|
|
@@ -47135,10 +47229,12 @@ var require_constructors = __commonJS({
|
|
|
47135
47229
|
);
|
|
47136
47230
|
if (constructorFunction2) {
|
|
47137
47231
|
constructorFunction2 = types_1.FunctionType.clone(constructorFunction2);
|
|
47232
|
+
constructorFunction2.details.typeVarScopeId = newSubtype.details.typeVarScopeId;
|
|
47138
47233
|
if (!constructorFunction2.details.docString && classType.details.docString) {
|
|
47139
47234
|
constructorFunction2.details.docString = classType.details.docString;
|
|
47140
47235
|
}
|
|
47141
47236
|
constructorFunction2.details.flags &= ~(4 | 1);
|
|
47237
|
+
constructorFunction2.details.constructorTypeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(classType);
|
|
47142
47238
|
}
|
|
47143
47239
|
return constructorFunction2;
|
|
47144
47240
|
};
|
|
@@ -47574,6 +47670,7 @@ var require_dataClasses = __commonJS({
|
|
|
47574
47670
|
var diagnosticRules_1 = require_diagnosticRules();
|
|
47575
47671
|
var localize_1 = require_localize();
|
|
47576
47672
|
var AnalyzerNodeInfo = __importStar(require_analyzerNodeInfo());
|
|
47673
|
+
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
47577
47674
|
var constructors_1 = require_constructors();
|
|
47578
47675
|
var namedTuples_1 = require_namedTuples();
|
|
47579
47676
|
var parseTreeUtils_1 = require_parseTreeUtils();
|
|
@@ -47888,7 +47985,9 @@ var require_dataClasses = __commonJS({
|
|
|
47888
47985
|
}
|
|
47889
47986
|
effectiveType = transformDescriptorType(evaluator, effectiveType);
|
|
47890
47987
|
if (entry.converter) {
|
|
47988
|
+
const fieldType = effectiveType;
|
|
47891
47989
|
effectiveType = getConverterInputType(evaluator, entry.converter, effectiveType, entry.name);
|
|
47990
|
+
symbolTable.set(entry.name, getDescriptorForConverterField(evaluator, node, entry.converter, entry.name, fieldType, effectiveType));
|
|
47892
47991
|
}
|
|
47893
47992
|
const effectiveName = entry.alias || entry.name;
|
|
47894
47993
|
if (!entry.alias && entry.nameNode && (0, symbolNameUtils_1.isPrivateName)(entry.nameNode.value)) {
|
|
@@ -48078,6 +48177,75 @@ var require_dataClasses = __commonJS({
|
|
|
48078
48177
|
}
|
|
48079
48178
|
return void 0;
|
|
48080
48179
|
}
|
|
48180
|
+
function getDescriptorForConverterField(evaluator, dataclassNode, converterNode, fieldName, getType, setType) {
|
|
48181
|
+
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(dataclassNode);
|
|
48182
|
+
const typeMetaclass = evaluator.getBuiltInType(dataclassNode, "type");
|
|
48183
|
+
const descriptorName = `__converterDescriptor_${fieldName}`;
|
|
48184
|
+
const descriptorClass = types_1.ClassType.createInstantiable(
|
|
48185
|
+
descriptorName,
|
|
48186
|
+
(0, parseTreeUtils_1.getClassFullName)(converterNode, fileInfo.moduleName, descriptorName),
|
|
48187
|
+
fileInfo.moduleName,
|
|
48188
|
+
fileInfo.filePath,
|
|
48189
|
+
0,
|
|
48190
|
+
(0, parseTreeUtils_1.getTypeSourceId)(converterNode),
|
|
48191
|
+
/* declaredMetaclass */
|
|
48192
|
+
void 0,
|
|
48193
|
+
(0, types_1.isInstantiableClass)(typeMetaclass) ? typeMetaclass : types_1.UnknownType.create()
|
|
48194
|
+
);
|
|
48195
|
+
descriptorClass.details.baseClasses.push(evaluator.getBuiltInType(dataclassNode, "object"));
|
|
48196
|
+
(0, typeUtils_1.computeMroLinearization)(descriptorClass);
|
|
48197
|
+
const fields = descriptorClass.details.fields;
|
|
48198
|
+
const selfType = (0, typeUtils_1.synthesizeTypeVarForSelfCls)(
|
|
48199
|
+
descriptorClass,
|
|
48200
|
+
/* isClsParam */
|
|
48201
|
+
false
|
|
48202
|
+
);
|
|
48203
|
+
const setFunction = types_1.FunctionType.createSynthesizedInstance("__set__");
|
|
48204
|
+
types_1.FunctionType.addParameter(setFunction, {
|
|
48205
|
+
category: 0,
|
|
48206
|
+
name: "self",
|
|
48207
|
+
type: selfType,
|
|
48208
|
+
hasDeclaredType: true
|
|
48209
|
+
});
|
|
48210
|
+
types_1.FunctionType.addParameter(setFunction, {
|
|
48211
|
+
category: 0,
|
|
48212
|
+
name: "obj",
|
|
48213
|
+
type: types_1.AnyType.create(),
|
|
48214
|
+
hasDeclaredType: true
|
|
48215
|
+
});
|
|
48216
|
+
types_1.FunctionType.addParameter(setFunction, {
|
|
48217
|
+
category: 0,
|
|
48218
|
+
name: "value",
|
|
48219
|
+
type: setType,
|
|
48220
|
+
hasDeclaredType: true
|
|
48221
|
+
});
|
|
48222
|
+
setFunction.details.declaredReturnType = types_1.NoneType.createInstance();
|
|
48223
|
+
const setSymbol = symbol_1.Symbol.createWithType(4, setFunction);
|
|
48224
|
+
fields.set("__set__", setSymbol);
|
|
48225
|
+
const getFunction = types_1.FunctionType.createSynthesizedInstance("__get__");
|
|
48226
|
+
types_1.FunctionType.addParameter(getFunction, {
|
|
48227
|
+
category: 0,
|
|
48228
|
+
name: "self",
|
|
48229
|
+
type: selfType,
|
|
48230
|
+
hasDeclaredType: true
|
|
48231
|
+
});
|
|
48232
|
+
types_1.FunctionType.addParameter(getFunction, {
|
|
48233
|
+
category: 0,
|
|
48234
|
+
name: "obj",
|
|
48235
|
+
type: types_1.AnyType.create(),
|
|
48236
|
+
hasDeclaredType: true
|
|
48237
|
+
});
|
|
48238
|
+
types_1.FunctionType.addParameter(getFunction, {
|
|
48239
|
+
category: 0,
|
|
48240
|
+
name: "objtype",
|
|
48241
|
+
type: types_1.AnyType.create(),
|
|
48242
|
+
hasDeclaredType: true
|
|
48243
|
+
});
|
|
48244
|
+
getFunction.details.declaredReturnType = getType;
|
|
48245
|
+
const getSymbol = symbol_1.Symbol.createWithType(4, getFunction);
|
|
48246
|
+
fields.set("__get__", getSymbol);
|
|
48247
|
+
return symbol_1.Symbol.createWithType(4, types_1.ClassType.cloneAsInstance(descriptorClass));
|
|
48248
|
+
}
|
|
48081
48249
|
function transformDescriptorType(evaluator, type) {
|
|
48082
48250
|
if (!(0, types_1.isClassInstance)(type)) {
|
|
48083
48251
|
return type;
|
|
@@ -48364,6 +48532,783 @@ var require_dataClasses = __commonJS({
|
|
|
48364
48532
|
}
|
|
48365
48533
|
});
|
|
48366
48534
|
|
|
48535
|
+
// node_modules/@zzzen/pyright-internal/dist/analyzer/properties.js
|
|
48536
|
+
var require_properties = __commonJS({
|
|
48537
|
+
"node_modules/@zzzen/pyright-internal/dist/analyzer/properties.js"(exports) {
|
|
48538
|
+
"use strict";
|
|
48539
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48540
|
+
exports.assignProperty = exports.clonePropertyWithDeleter = exports.clonePropertyWithSetter = exports.createProperty = exports.validatePropertyMethod = void 0;
|
|
48541
|
+
var diagnostic_1 = require_diagnostic();
|
|
48542
|
+
var diagnosticRules_1 = require_diagnosticRules();
|
|
48543
|
+
var localize_1 = require_localize();
|
|
48544
|
+
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
48545
|
+
var parseTreeUtils_1 = require_parseTreeUtils();
|
|
48546
|
+
var symbol_1 = require_symbol();
|
|
48547
|
+
var types_1 = require_types();
|
|
48548
|
+
var typeUtils_1 = require_typeUtils();
|
|
48549
|
+
function validatePropertyMethod(evaluator, method2, errorNode) {
|
|
48550
|
+
if (types_1.FunctionType.isStaticMethod(method2)) {
|
|
48551
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.propertyStaticMethod(), errorNode);
|
|
48552
|
+
}
|
|
48553
|
+
}
|
|
48554
|
+
exports.validatePropertyMethod = validatePropertyMethod;
|
|
48555
|
+
function createProperty(evaluator, decoratorNode, decoratorType, fget) {
|
|
48556
|
+
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(decoratorNode);
|
|
48557
|
+
const typeMetaclass = evaluator.getBuiltInType(decoratorNode, "type");
|
|
48558
|
+
const typeSourceId = types_1.ClassType.isBuiltIn(decoratorType, "property") ? (0, parseTreeUtils_1.getTypeSourceId)(decoratorNode) : decoratorType.details.typeSourceId;
|
|
48559
|
+
const propertyClass = types_1.ClassType.createInstantiable(
|
|
48560
|
+
decoratorType.details.name,
|
|
48561
|
+
(0, parseTreeUtils_1.getClassFullName)(decoratorNode, fileInfo.moduleName, `__property_${fget.details.name}`),
|
|
48562
|
+
fileInfo.moduleName,
|
|
48563
|
+
fileInfo.filePath,
|
|
48564
|
+
2048 | 1,
|
|
48565
|
+
typeSourceId,
|
|
48566
|
+
/* declaredMetaclass */
|
|
48567
|
+
void 0,
|
|
48568
|
+
(0, types_1.isInstantiableClass)(typeMetaclass) ? typeMetaclass : types_1.UnknownType.create()
|
|
48569
|
+
);
|
|
48570
|
+
propertyClass.details.typeVarScopeId = decoratorType.details.typeVarScopeId;
|
|
48571
|
+
const objectType = evaluator.getBuiltInType(decoratorNode, "object");
|
|
48572
|
+
propertyClass.details.baseClasses.push((0, types_1.isInstantiableClass)(objectType) ? objectType : types_1.UnknownType.create());
|
|
48573
|
+
(0, typeUtils_1.computeMroLinearization)(propertyClass);
|
|
48574
|
+
const fields = propertyClass.details.fields;
|
|
48575
|
+
decoratorType.details.fields.forEach((symbol, name) => {
|
|
48576
|
+
const ignoredMethods = ["__get__", "__set__", "__delete__", "fget", "fset", "fdel"];
|
|
48577
|
+
if (!symbol.isIgnoredForProtocolMatch()) {
|
|
48578
|
+
if (!ignoredMethods.some((m) => m === name)) {
|
|
48579
|
+
fields.set(name, symbol);
|
|
48580
|
+
}
|
|
48581
|
+
}
|
|
48582
|
+
});
|
|
48583
|
+
const propertyObject = types_1.ClassType.cloneAsInstance(propertyClass);
|
|
48584
|
+
propertyClass.isAsymmetricDescriptor = false;
|
|
48585
|
+
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
48586
|
+
const fgetSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
48587
|
+
fget,
|
|
48588
|
+
fget.details.flags | 4
|
|
48589
|
+
/* StaticMethod */
|
|
48590
|
+
));
|
|
48591
|
+
fields.set("fget", fgetSymbol);
|
|
48592
|
+
if (types_1.FunctionType.isClassMethod(fget)) {
|
|
48593
|
+
propertyClass.details.flags |= 4194304;
|
|
48594
|
+
}
|
|
48595
|
+
addGetMethodToPropertySymbolTable(evaluator, propertyObject, fget);
|
|
48596
|
+
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
48597
|
+
return propertyObject;
|
|
48598
|
+
}
|
|
48599
|
+
exports.createProperty = createProperty;
|
|
48600
|
+
function clonePropertyWithSetter(evaluator, prop, fset, errorNode) {
|
|
48601
|
+
if (!(0, typeUtils_1.isProperty)(prop)) {
|
|
48602
|
+
return prop;
|
|
48603
|
+
}
|
|
48604
|
+
const classType = prop;
|
|
48605
|
+
const flagsToClone = classType.details.flags;
|
|
48606
|
+
let isAsymmetricDescriptor = !!classType.isAsymmetricDescriptor;
|
|
48607
|
+
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
|
48608
|
+
if (errorNode.parameters.length >= 2) {
|
|
48609
|
+
const typeAnnotation = (0, parseTreeUtils_1.getTypeAnnotationForParameter)(errorNode, 1);
|
|
48610
|
+
if (typeAnnotation) {
|
|
48611
|
+
const fgetType = evaluator.getGetterTypeFromProperty(
|
|
48612
|
+
classType,
|
|
48613
|
+
/* inferTypeIfNeeded */
|
|
48614
|
+
false
|
|
48615
|
+
);
|
|
48616
|
+
if (fgetType && !(0, types_1.isAnyOrUnknown)(fgetType)) {
|
|
48617
|
+
const fsetType = evaluator.getTypeOfAnnotation(typeAnnotation, {
|
|
48618
|
+
associateTypeVarsWithScope: true
|
|
48619
|
+
});
|
|
48620
|
+
if (fileInfo.diagnosticRuleSet.reportPropertyTypeMismatch !== "none") {
|
|
48621
|
+
const diag = new diagnostic_1.DiagnosticAddendum();
|
|
48622
|
+
if (!evaluator.assignType(fgetType, fsetType, diag)) {
|
|
48623
|
+
evaluator.addDiagnostic(fileInfo.diagnosticRuleSet.reportPropertyTypeMismatch, diagnosticRules_1.DiagnosticRule.reportPropertyTypeMismatch, localize_1.Localizer.Diagnostic.setterGetterTypeMismatch() + diag.getString(), typeAnnotation);
|
|
48624
|
+
}
|
|
48625
|
+
}
|
|
48626
|
+
if (!(0, types_1.isTypeSame)(fgetType, fsetType)) {
|
|
48627
|
+
isAsymmetricDescriptor = true;
|
|
48628
|
+
}
|
|
48629
|
+
}
|
|
48630
|
+
}
|
|
48631
|
+
}
|
|
48632
|
+
const propertyClass = types_1.ClassType.createInstantiable(classType.details.name, classType.details.fullName, classType.details.moduleName, (0, analyzerNodeInfo_1.getFileInfo)(errorNode).filePath, flagsToClone, classType.details.typeSourceId, classType.details.declaredMetaclass, classType.details.effectiveMetaclass);
|
|
48633
|
+
propertyClass.details.typeVarScopeId = classType.details.typeVarScopeId;
|
|
48634
|
+
const objectType = evaluator.getBuiltInType(errorNode, "object");
|
|
48635
|
+
propertyClass.details.baseClasses.push((0, types_1.isInstantiableClass)(objectType) ? objectType : types_1.UnknownType.create());
|
|
48636
|
+
(0, typeUtils_1.computeMroLinearization)(propertyClass);
|
|
48637
|
+
propertyClass.isAsymmetricDescriptor = isAsymmetricDescriptor;
|
|
48638
|
+
const propertyObject = types_1.ClassType.cloneAsInstance(propertyClass);
|
|
48639
|
+
const fields = propertyClass.details.fields;
|
|
48640
|
+
classType.details.fields.forEach((symbol, name) => {
|
|
48641
|
+
if (!symbol.isIgnoredForProtocolMatch()) {
|
|
48642
|
+
fields.set(name, symbol);
|
|
48643
|
+
}
|
|
48644
|
+
});
|
|
48645
|
+
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
48646
|
+
const fsetSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
48647
|
+
fset,
|
|
48648
|
+
fset.details.flags | 4
|
|
48649
|
+
/* StaticMethod */
|
|
48650
|
+
));
|
|
48651
|
+
fields.set("fset", fsetSymbol);
|
|
48652
|
+
addSetMethodToPropertySymbolTable(evaluator, propertyObject, fset);
|
|
48653
|
+
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
48654
|
+
return propertyObject;
|
|
48655
|
+
}
|
|
48656
|
+
exports.clonePropertyWithSetter = clonePropertyWithSetter;
|
|
48657
|
+
function clonePropertyWithDeleter(evaluator, prop, fdel, errorNode) {
|
|
48658
|
+
var _a;
|
|
48659
|
+
if (!(0, typeUtils_1.isProperty)(prop)) {
|
|
48660
|
+
return prop;
|
|
48661
|
+
}
|
|
48662
|
+
const classType = prop;
|
|
48663
|
+
const propertyClass = types_1.ClassType.createInstantiable(classType.details.name, classType.details.fullName, classType.details.moduleName, (0, analyzerNodeInfo_1.getFileInfo)(errorNode).filePath, classType.details.flags, classType.details.typeSourceId, classType.details.declaredMetaclass, classType.details.effectiveMetaclass);
|
|
48664
|
+
propertyClass.details.typeVarScopeId = classType.details.typeVarScopeId;
|
|
48665
|
+
const objectType = evaluator.getBuiltInType(errorNode, "object");
|
|
48666
|
+
propertyClass.details.baseClasses.push((0, types_1.isInstantiableClass)(objectType) ? objectType : types_1.UnknownType.create());
|
|
48667
|
+
(0, typeUtils_1.computeMroLinearization)(propertyClass);
|
|
48668
|
+
const propertyObject = types_1.ClassType.cloneAsInstance(propertyClass);
|
|
48669
|
+
propertyClass.isAsymmetricDescriptor = (_a = classType.isAsymmetricDescriptor) !== null && _a !== void 0 ? _a : false;
|
|
48670
|
+
const fields = propertyClass.details.fields;
|
|
48671
|
+
classType.details.fields.forEach((symbol, name) => {
|
|
48672
|
+
if (!symbol.isIgnoredForProtocolMatch()) {
|
|
48673
|
+
fields.set(name, symbol);
|
|
48674
|
+
}
|
|
48675
|
+
});
|
|
48676
|
+
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
48677
|
+
const fdelSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
48678
|
+
fdel,
|
|
48679
|
+
fdel.details.flags | 4
|
|
48680
|
+
/* StaticMethod */
|
|
48681
|
+
));
|
|
48682
|
+
fields.set("fdel", fdelSymbol);
|
|
48683
|
+
addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdel);
|
|
48684
|
+
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
48685
|
+
return propertyObject;
|
|
48686
|
+
}
|
|
48687
|
+
exports.clonePropertyWithDeleter = clonePropertyWithDeleter;
|
|
48688
|
+
function addGetMethodToPropertySymbolTable(evaluator, propertyObject, fget) {
|
|
48689
|
+
const fields = propertyObject.details.fields;
|
|
48690
|
+
const getFunction1 = types_1.FunctionType.createSynthesizedInstance(
|
|
48691
|
+
"__get__",
|
|
48692
|
+
256
|
|
48693
|
+
/* Overloaded */
|
|
48694
|
+
);
|
|
48695
|
+
types_1.FunctionType.addParameter(getFunction1, {
|
|
48696
|
+
category: 0,
|
|
48697
|
+
name: "self",
|
|
48698
|
+
type: types_1.AnyType.create(),
|
|
48699
|
+
hasDeclaredType: true
|
|
48700
|
+
});
|
|
48701
|
+
types_1.FunctionType.addParameter(getFunction1, {
|
|
48702
|
+
category: 0,
|
|
48703
|
+
name: "obj",
|
|
48704
|
+
type: types_1.NoneType.createInstance(),
|
|
48705
|
+
hasDeclaredType: true
|
|
48706
|
+
});
|
|
48707
|
+
types_1.FunctionType.addParameter(getFunction1, {
|
|
48708
|
+
category: 0,
|
|
48709
|
+
name: "objtype",
|
|
48710
|
+
type: types_1.AnyType.create(),
|
|
48711
|
+
hasDeclaredType: true,
|
|
48712
|
+
hasDefault: true,
|
|
48713
|
+
defaultType: types_1.AnyType.create()
|
|
48714
|
+
});
|
|
48715
|
+
getFunction1.details.declaredReturnType = types_1.FunctionType.isClassMethod(fget) ? types_1.FunctionType.getSpecializedReturnType(fget) : propertyObject;
|
|
48716
|
+
getFunction1.details.declaration = fget.details.declaration;
|
|
48717
|
+
getFunction1.details.typeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(fget);
|
|
48718
|
+
const getFunction2 = types_1.FunctionType.createSynthesizedInstance(
|
|
48719
|
+
"__get__",
|
|
48720
|
+
256
|
|
48721
|
+
/* Overloaded */
|
|
48722
|
+
);
|
|
48723
|
+
types_1.FunctionType.addParameter(getFunction2, {
|
|
48724
|
+
category: 0,
|
|
48725
|
+
name: "self",
|
|
48726
|
+
type: types_1.AnyType.create(),
|
|
48727
|
+
hasDeclaredType: true
|
|
48728
|
+
});
|
|
48729
|
+
const objType = fget.details.parameters.length > 0 ? fget.details.parameters[0].type : types_1.AnyType.create();
|
|
48730
|
+
types_1.FunctionType.addParameter(getFunction2, {
|
|
48731
|
+
category: 0,
|
|
48732
|
+
name: "obj",
|
|
48733
|
+
type: objType,
|
|
48734
|
+
hasDeclaredType: true
|
|
48735
|
+
});
|
|
48736
|
+
types_1.FunctionType.addParameter(getFunction2, {
|
|
48737
|
+
category: 0,
|
|
48738
|
+
name: "objtype",
|
|
48739
|
+
type: types_1.AnyType.create(),
|
|
48740
|
+
hasDeclaredType: true,
|
|
48741
|
+
hasDefault: true,
|
|
48742
|
+
defaultType: types_1.AnyType.create()
|
|
48743
|
+
});
|
|
48744
|
+
getFunction2.details.declaredReturnType = types_1.FunctionType.getSpecializedReturnType(fget);
|
|
48745
|
+
getFunction2.details.declaration = fget.details.declaration;
|
|
48746
|
+
getFunction2.details.typeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(fget);
|
|
48747
|
+
const getFunctionOverload = types_1.OverloadedFunctionType.create([getFunction2, getFunction1]);
|
|
48748
|
+
const getSymbol = symbol_1.Symbol.createWithType(4, getFunctionOverload);
|
|
48749
|
+
fields.set("__get__", getSymbol);
|
|
48750
|
+
}
|
|
48751
|
+
function addSetMethodToPropertySymbolTable(evaluator, propertyObject, fset) {
|
|
48752
|
+
const fields = propertyObject.details.fields;
|
|
48753
|
+
const setFunction = types_1.FunctionType.createSynthesizedInstance("__set__");
|
|
48754
|
+
types_1.FunctionType.addParameter(setFunction, {
|
|
48755
|
+
category: 0,
|
|
48756
|
+
name: "self",
|
|
48757
|
+
type: types_1.AnyType.create(),
|
|
48758
|
+
hasDeclaredType: true
|
|
48759
|
+
});
|
|
48760
|
+
let objType = fset.details.parameters.length > 0 ? fset.details.parameters[0].type : types_1.AnyType.create();
|
|
48761
|
+
if ((0, types_1.isTypeVar)(objType) && objType.details.isSynthesizedSelf) {
|
|
48762
|
+
objType = evaluator.makeTopLevelTypeVarsConcrete(objType);
|
|
48763
|
+
}
|
|
48764
|
+
types_1.FunctionType.addParameter(setFunction, {
|
|
48765
|
+
category: 0,
|
|
48766
|
+
name: "obj",
|
|
48767
|
+
type: (0, types_1.combineTypes)([objType, types_1.NoneType.createInstance()]),
|
|
48768
|
+
hasDeclaredType: true
|
|
48769
|
+
});
|
|
48770
|
+
setFunction.details.declaredReturnType = types_1.NoneType.createInstance();
|
|
48771
|
+
setFunction.details.typeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(fset);
|
|
48772
|
+
let setParamType = types_1.UnknownType.create();
|
|
48773
|
+
if (fset.details.parameters.length >= 2 && fset.details.parameters[1].category === 0 && fset.details.parameters[1].name) {
|
|
48774
|
+
setParamType = fset.details.parameters[1].type;
|
|
48775
|
+
}
|
|
48776
|
+
types_1.FunctionType.addParameter(setFunction, {
|
|
48777
|
+
category: 0,
|
|
48778
|
+
name: "value",
|
|
48779
|
+
type: setParamType,
|
|
48780
|
+
hasDeclaredType: true
|
|
48781
|
+
});
|
|
48782
|
+
const setSymbol = symbol_1.Symbol.createWithType(4, setFunction);
|
|
48783
|
+
fields.set("__set__", setSymbol);
|
|
48784
|
+
}
|
|
48785
|
+
function addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdel) {
|
|
48786
|
+
const fields = propertyObject.details.fields;
|
|
48787
|
+
const delFunction = types_1.FunctionType.createSynthesizedInstance("__delete__");
|
|
48788
|
+
types_1.FunctionType.addParameter(delFunction, {
|
|
48789
|
+
category: 0,
|
|
48790
|
+
name: "self",
|
|
48791
|
+
type: types_1.AnyType.create(),
|
|
48792
|
+
hasDeclaredType: true
|
|
48793
|
+
});
|
|
48794
|
+
delFunction.details.typeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(fdel);
|
|
48795
|
+
let objType = fdel.details.parameters.length > 0 ? fdel.details.parameters[0].type : types_1.AnyType.create();
|
|
48796
|
+
if ((0, types_1.isTypeVar)(objType) && objType.details.isSynthesizedSelf) {
|
|
48797
|
+
objType = evaluator.makeTopLevelTypeVarsConcrete(objType);
|
|
48798
|
+
}
|
|
48799
|
+
types_1.FunctionType.addParameter(delFunction, {
|
|
48800
|
+
category: 0,
|
|
48801
|
+
name: "obj",
|
|
48802
|
+
type: (0, types_1.combineTypes)([objType, types_1.NoneType.createInstance()]),
|
|
48803
|
+
hasDeclaredType: true
|
|
48804
|
+
});
|
|
48805
|
+
delFunction.details.declaredReturnType = types_1.NoneType.createInstance();
|
|
48806
|
+
const delSymbol = symbol_1.Symbol.createWithType(4, delFunction);
|
|
48807
|
+
fields.set("__delete__", delSymbol);
|
|
48808
|
+
}
|
|
48809
|
+
function updateGetSetDelMethodForClonedProperty(evaluator, propertyObject) {
|
|
48810
|
+
const fields = propertyObject.details.fields;
|
|
48811
|
+
const fgetSymbol = fields.get("fget");
|
|
48812
|
+
const fgetType = fgetSymbol === null || fgetSymbol === void 0 ? void 0 : fgetSymbol.getSynthesizedType();
|
|
48813
|
+
if (fgetType && (0, types_1.isFunction)(fgetType)) {
|
|
48814
|
+
addGetMethodToPropertySymbolTable(evaluator, propertyObject, fgetType);
|
|
48815
|
+
}
|
|
48816
|
+
const fsetSymbol = fields.get("fset");
|
|
48817
|
+
const fsetType = fsetSymbol === null || fsetSymbol === void 0 ? void 0 : fsetSymbol.getSynthesizedType();
|
|
48818
|
+
if (fsetType && (0, types_1.isFunction)(fsetType)) {
|
|
48819
|
+
addSetMethodToPropertySymbolTable(evaluator, propertyObject, fsetType);
|
|
48820
|
+
}
|
|
48821
|
+
const fdelSymbol = fields.get("fdel");
|
|
48822
|
+
const fdelType = fdelSymbol === null || fdelSymbol === void 0 ? void 0 : fdelSymbol.getSynthesizedType();
|
|
48823
|
+
if (fdelType && (0, types_1.isFunction)(fdelType)) {
|
|
48824
|
+
addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdelType);
|
|
48825
|
+
}
|
|
48826
|
+
}
|
|
48827
|
+
function addDecoratorMethodsToPropertySymbolTable(propertyObject) {
|
|
48828
|
+
const fields = propertyObject.details.fields;
|
|
48829
|
+
["getter", "setter", "deleter"].forEach((accessorName) => {
|
|
48830
|
+
const accessorFunction = types_1.FunctionType.createSynthesizedInstance(accessorName);
|
|
48831
|
+
types_1.FunctionType.addParameter(accessorFunction, {
|
|
48832
|
+
category: 0,
|
|
48833
|
+
name: "self",
|
|
48834
|
+
type: types_1.AnyType.create(),
|
|
48835
|
+
hasDeclaredType: true
|
|
48836
|
+
});
|
|
48837
|
+
types_1.FunctionType.addParameter(accessorFunction, {
|
|
48838
|
+
category: 0,
|
|
48839
|
+
name: "accessor",
|
|
48840
|
+
type: types_1.AnyType.create(),
|
|
48841
|
+
hasDeclaredType: true
|
|
48842
|
+
});
|
|
48843
|
+
accessorFunction.details.declaredReturnType = propertyObject;
|
|
48844
|
+
const accessorSymbol = symbol_1.Symbol.createWithType(4, accessorFunction);
|
|
48845
|
+
fields.set(accessorName, accessorSymbol);
|
|
48846
|
+
});
|
|
48847
|
+
}
|
|
48848
|
+
function assignProperty(evaluator, destPropertyType, srcPropertyType, destClass, srcClass, diag, typeVarContext, selfTypeVarContext, recursionCount = 0) {
|
|
48849
|
+
const srcObjectToBind = types_1.ClassType.cloneAsInstance(srcClass);
|
|
48850
|
+
const destObjectToBind = types_1.ClassType.cloneAsInstance(destClass);
|
|
48851
|
+
let isAssignable = true;
|
|
48852
|
+
const accessors = [
|
|
48853
|
+
{
|
|
48854
|
+
name: "fget",
|
|
48855
|
+
missingDiagMsg: localize_1.Localizer.DiagnosticAddendum.missingGetter,
|
|
48856
|
+
incompatibleDiagMsg: localize_1.Localizer.DiagnosticAddendum.incompatibleGetter
|
|
48857
|
+
},
|
|
48858
|
+
{
|
|
48859
|
+
name: "fset",
|
|
48860
|
+
missingDiagMsg: localize_1.Localizer.DiagnosticAddendum.missingSetter,
|
|
48861
|
+
incompatibleDiagMsg: localize_1.Localizer.DiagnosticAddendum.incompatibleSetter
|
|
48862
|
+
},
|
|
48863
|
+
{
|
|
48864
|
+
name: "fdel",
|
|
48865
|
+
missingDiagMsg: localize_1.Localizer.DiagnosticAddendum.missingDeleter,
|
|
48866
|
+
incompatibleDiagMsg: localize_1.Localizer.DiagnosticAddendum.incompatibleDeleter
|
|
48867
|
+
}
|
|
48868
|
+
];
|
|
48869
|
+
accessors.forEach((accessorInfo) => {
|
|
48870
|
+
var _a, _b;
|
|
48871
|
+
const destAccessSymbol = destPropertyType.details.fields.get(accessorInfo.name);
|
|
48872
|
+
let destAccessType = destAccessSymbol ? (_a = evaluator.getDeclaredTypeOfSymbol(destAccessSymbol)) === null || _a === void 0 ? void 0 : _a.type : void 0;
|
|
48873
|
+
if (destAccessType && (0, types_1.isFunction)(destAccessType)) {
|
|
48874
|
+
const srcAccessSymbol = srcPropertyType.details.fields.get(accessorInfo.name);
|
|
48875
|
+
let srcAccessType = srcAccessSymbol ? (_b = evaluator.getDeclaredTypeOfSymbol(srcAccessSymbol)) === null || _b === void 0 ? void 0 : _b.type : void 0;
|
|
48876
|
+
if (!srcAccessType || !(0, types_1.isFunction)(srcAccessType)) {
|
|
48877
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(accessorInfo.missingDiagMsg());
|
|
48878
|
+
isAssignable = false;
|
|
48879
|
+
return;
|
|
48880
|
+
}
|
|
48881
|
+
evaluator.inferReturnTypeIfNecessary(srcAccessType);
|
|
48882
|
+
srcAccessType = (0, typeUtils_1.partiallySpecializeType)(srcAccessType, srcClass);
|
|
48883
|
+
evaluator.inferReturnTypeIfNecessary(destAccessType);
|
|
48884
|
+
destAccessType = (0, typeUtils_1.partiallySpecializeType)(destAccessType, destClass);
|
|
48885
|
+
if (selfTypeVarContext) {
|
|
48886
|
+
destAccessType = (0, typeUtils_1.applySolvedTypeVars)(destAccessType, selfTypeVarContext);
|
|
48887
|
+
}
|
|
48888
|
+
destAccessType = types_1.FunctionType.cloneWithNewFlags(
|
|
48889
|
+
destAccessType,
|
|
48890
|
+
destAccessType.details.flags & ~4
|
|
48891
|
+
/* StaticMethod */
|
|
48892
|
+
);
|
|
48893
|
+
srcAccessType = types_1.FunctionType.cloneWithNewFlags(
|
|
48894
|
+
srcAccessType,
|
|
48895
|
+
srcAccessType.details.flags & ~4
|
|
48896
|
+
/* StaticMethod */
|
|
48897
|
+
);
|
|
48898
|
+
const boundDestAccessType = evaluator.bindFunctionToClassOrObject(
|
|
48899
|
+
destObjectToBind,
|
|
48900
|
+
destAccessType,
|
|
48901
|
+
/* memberClass */
|
|
48902
|
+
void 0,
|
|
48903
|
+
/* errorNode */
|
|
48904
|
+
void 0,
|
|
48905
|
+
recursionCount
|
|
48906
|
+
);
|
|
48907
|
+
const boundSrcAccessType = evaluator.bindFunctionToClassOrObject(
|
|
48908
|
+
srcObjectToBind,
|
|
48909
|
+
srcAccessType,
|
|
48910
|
+
/* memberClass */
|
|
48911
|
+
void 0,
|
|
48912
|
+
/* errorNode */
|
|
48913
|
+
void 0,
|
|
48914
|
+
recursionCount
|
|
48915
|
+
);
|
|
48916
|
+
if (!boundDestAccessType || !boundSrcAccessType || !evaluator.assignType(
|
|
48917
|
+
boundDestAccessType,
|
|
48918
|
+
boundSrcAccessType,
|
|
48919
|
+
diag,
|
|
48920
|
+
typeVarContext,
|
|
48921
|
+
/* srcTypeVarContext */
|
|
48922
|
+
void 0,
|
|
48923
|
+
0,
|
|
48924
|
+
recursionCount
|
|
48925
|
+
)) {
|
|
48926
|
+
isAssignable = false;
|
|
48927
|
+
}
|
|
48928
|
+
}
|
|
48929
|
+
});
|
|
48930
|
+
return isAssignable;
|
|
48931
|
+
}
|
|
48932
|
+
exports.assignProperty = assignProperty;
|
|
48933
|
+
}
|
|
48934
|
+
});
|
|
48935
|
+
|
|
48936
|
+
// node_modules/@zzzen/pyright-internal/dist/analyzer/decorators.js
|
|
48937
|
+
var require_decorators = __commonJS({
|
|
48938
|
+
"node_modules/@zzzen/pyright-internal/dist/analyzer/decorators.js"(exports) {
|
|
48939
|
+
"use strict";
|
|
48940
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48941
|
+
exports.addOverloadsToFunctionType = exports.applyClassDecorator = exports.applyFunctionDecorator = exports.getFunctionFlagsFromDecorators = void 0;
|
|
48942
|
+
var collectionUtils_1 = require_collectionUtils();
|
|
48943
|
+
var diagnosticRules_1 = require_diagnosticRules();
|
|
48944
|
+
var localize_1 = require_localize();
|
|
48945
|
+
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
48946
|
+
var dataClasses_1 = require_dataClasses();
|
|
48947
|
+
var properties_1 = require_properties();
|
|
48948
|
+
var typeUtils_1 = require_typeUtils();
|
|
48949
|
+
var types_1 = require_types();
|
|
48950
|
+
function getFunctionFlagsFromDecorators(evaluator, node, isInClass) {
|
|
48951
|
+
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(node);
|
|
48952
|
+
let flags = 0;
|
|
48953
|
+
if (isInClass) {
|
|
48954
|
+
if (node.name.value === "__new__") {
|
|
48955
|
+
flags |= 1;
|
|
48956
|
+
}
|
|
48957
|
+
const implicitClassMethods = ["__init_subclass__", "__class_getitem__"];
|
|
48958
|
+
if (implicitClassMethods.some((name) => node.name.value === name)) {
|
|
48959
|
+
flags |= 2;
|
|
48960
|
+
}
|
|
48961
|
+
}
|
|
48962
|
+
for (const decoratorNode of node.decorators) {
|
|
48963
|
+
let evaluatorFlags = fileInfo.isStubFile ? 4 : 0;
|
|
48964
|
+
if (decoratorNode.expression.nodeType !== 9) {
|
|
48965
|
+
evaluatorFlags |= 2;
|
|
48966
|
+
}
|
|
48967
|
+
const decoratorTypeResult = evaluator.getTypeOfExpression(decoratorNode.expression, evaluatorFlags);
|
|
48968
|
+
const decoratorType = decoratorTypeResult.type;
|
|
48969
|
+
if ((0, types_1.isFunction)(decoratorType)) {
|
|
48970
|
+
if (decoratorType.details.builtInName === "abstractmethod") {
|
|
48971
|
+
if (isInClass) {
|
|
48972
|
+
flags |= 8;
|
|
48973
|
+
}
|
|
48974
|
+
} else if (decoratorType.details.builtInName === "final") {
|
|
48975
|
+
flags |= 8192;
|
|
48976
|
+
} else if (decoratorType.details.builtInName === "override") {
|
|
48977
|
+
flags |= 262144;
|
|
48978
|
+
}
|
|
48979
|
+
} else if ((0, types_1.isInstantiableClass)(decoratorType)) {
|
|
48980
|
+
if (types_1.ClassType.isBuiltIn(decoratorType, "staticmethod")) {
|
|
48981
|
+
if (isInClass) {
|
|
48982
|
+
flags |= 4;
|
|
48983
|
+
}
|
|
48984
|
+
} else if (types_1.ClassType.isBuiltIn(decoratorType, "classmethod")) {
|
|
48985
|
+
if (isInClass) {
|
|
48986
|
+
flags |= 2;
|
|
48987
|
+
}
|
|
48988
|
+
}
|
|
48989
|
+
}
|
|
48990
|
+
}
|
|
48991
|
+
return flags;
|
|
48992
|
+
}
|
|
48993
|
+
exports.getFunctionFlagsFromDecorators = getFunctionFlagsFromDecorators;
|
|
48994
|
+
function applyFunctionDecorator(evaluator, inputFunctionType, undecoratedType, decoratorNode, functionNode) {
|
|
48995
|
+
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(decoratorNode);
|
|
48996
|
+
let evaluatorFlags = fileInfo.isStubFile ? 4 : 0;
|
|
48997
|
+
if (decoratorNode.expression.nodeType !== 9) {
|
|
48998
|
+
evaluatorFlags |= 2;
|
|
48999
|
+
}
|
|
49000
|
+
const decoratorTypeResult = evaluator.getTypeOfExpression(decoratorNode.expression, evaluatorFlags);
|
|
49001
|
+
const decoratorType = decoratorTypeResult.type;
|
|
49002
|
+
if ((0, types_1.isInstantiableClass)(decoratorType) && types_1.ClassType.isSpecialBuiltIn(decoratorType, "overload") || (0, types_1.isFunction)(decoratorType) && decoratorType.details.builtInName === "overload") {
|
|
49003
|
+
if ((0, types_1.isFunction)(inputFunctionType)) {
|
|
49004
|
+
inputFunctionType.details.flags |= 256;
|
|
49005
|
+
undecoratedType.details.flags |= 256;
|
|
49006
|
+
return inputFunctionType;
|
|
49007
|
+
}
|
|
49008
|
+
}
|
|
49009
|
+
if (decoratorNode.expression.nodeType === 9) {
|
|
49010
|
+
const decoratorCallType = evaluator.getTypeOfExpression(
|
|
49011
|
+
decoratorNode.expression.leftExpression,
|
|
49012
|
+
evaluatorFlags | 2
|
|
49013
|
+
/* DoNotSpecialize */
|
|
49014
|
+
).type;
|
|
49015
|
+
if ((0, types_1.isFunction)(decoratorCallType)) {
|
|
49016
|
+
if (decoratorCallType.details.name === "__dataclass_transform__" || decoratorCallType.details.builtInName === "dataclass_transform") {
|
|
49017
|
+
undecoratedType.details.decoratorDataClassBehaviors = (0, dataClasses_1.validateDataClassTransformDecorator)(evaluator, decoratorNode.expression);
|
|
49018
|
+
return inputFunctionType;
|
|
49019
|
+
}
|
|
49020
|
+
if (decoratorCallType.details.builtInName === "deprecated") {
|
|
49021
|
+
undecoratedType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
49022
|
+
return inputFunctionType;
|
|
49023
|
+
}
|
|
49024
|
+
}
|
|
49025
|
+
if ((0, types_1.isOverloadedFunction)(decoratorCallType)) {
|
|
49026
|
+
if (decoratorCallType.overloads.length > 0 && decoratorCallType.overloads[0].details.builtInName === "deprecated") {
|
|
49027
|
+
undecoratedType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
49028
|
+
return inputFunctionType;
|
|
49029
|
+
}
|
|
49030
|
+
}
|
|
49031
|
+
}
|
|
49032
|
+
let returnType = getTypeOfDecorator(evaluator, decoratorNode, inputFunctionType);
|
|
49033
|
+
if ((0, types_1.isFunction)(decoratorType)) {
|
|
49034
|
+
if (decoratorType.details.builtInName === "abstractmethod") {
|
|
49035
|
+
return inputFunctionType;
|
|
49036
|
+
}
|
|
49037
|
+
if (decoratorType.details.builtInName === "deprecated") {
|
|
49038
|
+
undecoratedType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
49039
|
+
return inputFunctionType;
|
|
49040
|
+
}
|
|
49041
|
+
if (decoratorNode.expression.nodeType === 35) {
|
|
49042
|
+
const baseType = evaluator.getTypeOfExpression(
|
|
49043
|
+
decoratorNode.expression.leftExpression,
|
|
49044
|
+
evaluatorFlags | 2
|
|
49045
|
+
/* DoNotSpecialize */
|
|
49046
|
+
).type;
|
|
49047
|
+
if ((0, typeUtils_1.isProperty)(baseType)) {
|
|
49048
|
+
const memberName = decoratorNode.expression.memberName.value;
|
|
49049
|
+
if (memberName === "setter") {
|
|
49050
|
+
if ((0, types_1.isFunction)(inputFunctionType)) {
|
|
49051
|
+
(0, properties_1.validatePropertyMethod)(evaluator, inputFunctionType, decoratorNode);
|
|
49052
|
+
return (0, properties_1.clonePropertyWithSetter)(evaluator, baseType, inputFunctionType, functionNode);
|
|
49053
|
+
} else {
|
|
49054
|
+
return inputFunctionType;
|
|
49055
|
+
}
|
|
49056
|
+
} else if (memberName === "deleter") {
|
|
49057
|
+
if ((0, types_1.isFunction)(inputFunctionType)) {
|
|
49058
|
+
(0, properties_1.validatePropertyMethod)(evaluator, inputFunctionType, decoratorNode);
|
|
49059
|
+
return (0, properties_1.clonePropertyWithDeleter)(evaluator, baseType, inputFunctionType, functionNode);
|
|
49060
|
+
} else {
|
|
49061
|
+
return inputFunctionType;
|
|
49062
|
+
}
|
|
49063
|
+
}
|
|
49064
|
+
}
|
|
49065
|
+
}
|
|
49066
|
+
} else if ((0, types_1.isOverloadedFunction)(decoratorType)) {
|
|
49067
|
+
if (decoratorType.overloads.length > 0 && decoratorType.overloads[0].details.builtInName === "deprecated") {
|
|
49068
|
+
undecoratedType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
49069
|
+
return inputFunctionType;
|
|
49070
|
+
}
|
|
49071
|
+
} else if ((0, types_1.isInstantiableClass)(decoratorType)) {
|
|
49072
|
+
if (types_1.ClassType.isBuiltIn(decoratorType)) {
|
|
49073
|
+
switch (decoratorType.details.name) {
|
|
49074
|
+
case "classmethod":
|
|
49075
|
+
case "staticmethod": {
|
|
49076
|
+
const requiredFlag = decoratorType.details.name === "classmethod" ? 2 : 4;
|
|
49077
|
+
if ((0, types_1.isFunction)(inputFunctionType) && (inputFunctionType.details.flags & requiredFlag) === 0) {
|
|
49078
|
+
const newFunction = types_1.FunctionType.clone(inputFunctionType);
|
|
49079
|
+
newFunction.details.flags &= ~(1 | 4 | 2);
|
|
49080
|
+
newFunction.details.flags |= requiredFlag;
|
|
49081
|
+
return newFunction;
|
|
49082
|
+
}
|
|
49083
|
+
return inputFunctionType;
|
|
49084
|
+
}
|
|
49085
|
+
}
|
|
49086
|
+
}
|
|
49087
|
+
if (types_1.ClassType.isPropertyClass(decoratorType)) {
|
|
49088
|
+
if ((0, types_1.isFunction)(inputFunctionType)) {
|
|
49089
|
+
(0, properties_1.validatePropertyMethod)(evaluator, inputFunctionType, decoratorNode);
|
|
49090
|
+
return (0, properties_1.createProperty)(evaluator, decoratorNode, decoratorType, inputFunctionType);
|
|
49091
|
+
} else if ((0, types_1.isClassInstance)(inputFunctionType)) {
|
|
49092
|
+
const boundMethod = evaluator.getBoundMethod(inputFunctionType, "__call__");
|
|
49093
|
+
if (boundMethod && (0, types_1.isFunction)(boundMethod)) {
|
|
49094
|
+
return (0, properties_1.createProperty)(evaluator, decoratorNode, decoratorType, boundMethod);
|
|
49095
|
+
}
|
|
49096
|
+
return types_1.UnknownType.create();
|
|
49097
|
+
}
|
|
49098
|
+
}
|
|
49099
|
+
}
|
|
49100
|
+
if ((0, types_1.isFunction)(inputFunctionType) && (0, types_1.isFunction)(returnType)) {
|
|
49101
|
+
returnType = types_1.FunctionType.clone(returnType);
|
|
49102
|
+
if (types_1.FunctionType.isOverloaded(inputFunctionType)) {
|
|
49103
|
+
returnType.details.flags |= 256;
|
|
49104
|
+
}
|
|
49105
|
+
if (!returnType.details.docString) {
|
|
49106
|
+
returnType.details.docString = inputFunctionType.details.docString;
|
|
49107
|
+
}
|
|
49108
|
+
}
|
|
49109
|
+
return returnType;
|
|
49110
|
+
}
|
|
49111
|
+
exports.applyFunctionDecorator = applyFunctionDecorator;
|
|
49112
|
+
function applyClassDecorator(evaluator, inputClassType, originalClassType, decoratorNode) {
|
|
49113
|
+
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(decoratorNode);
|
|
49114
|
+
let flags = fileInfo.isStubFile ? 4 : 0;
|
|
49115
|
+
if (decoratorNode.expression.nodeType !== 9) {
|
|
49116
|
+
flags |= 2;
|
|
49117
|
+
}
|
|
49118
|
+
const decoratorType = evaluator.getTypeOfExpression(decoratorNode.expression, flags).type;
|
|
49119
|
+
if (decoratorNode.expression.nodeType === 9) {
|
|
49120
|
+
const decoratorCallType = evaluator.getTypeOfExpression(
|
|
49121
|
+
decoratorNode.expression.leftExpression,
|
|
49122
|
+
flags | 2
|
|
49123
|
+
/* DoNotSpecialize */
|
|
49124
|
+
).type;
|
|
49125
|
+
if ((0, types_1.isFunction)(decoratorCallType)) {
|
|
49126
|
+
if (decoratorCallType.details.name === "__dataclass_transform__" || decoratorCallType.details.builtInName === "dataclass_transform") {
|
|
49127
|
+
originalClassType.details.classDataClassTransform = (0, dataClasses_1.validateDataClassTransformDecorator)(evaluator, decoratorNode.expression);
|
|
49128
|
+
} else if (decoratorCallType.details.builtInName === "deprecated") {
|
|
49129
|
+
originalClassType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
49130
|
+
return inputClassType;
|
|
49131
|
+
}
|
|
49132
|
+
}
|
|
49133
|
+
if ((0, types_1.isOverloadedFunction)(decoratorCallType)) {
|
|
49134
|
+
if (decoratorCallType.overloads.length > 0 && decoratorCallType.overloads[0].details.builtInName === "deprecated") {
|
|
49135
|
+
originalClassType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
49136
|
+
return inputClassType;
|
|
49137
|
+
}
|
|
49138
|
+
}
|
|
49139
|
+
}
|
|
49140
|
+
if ((0, types_1.isOverloadedFunction)(decoratorType)) {
|
|
49141
|
+
const dataclassBehaviors = (0, dataClasses_1.getDataclassDecoratorBehaviors)(decoratorType);
|
|
49142
|
+
if (dataclassBehaviors) {
|
|
49143
|
+
(0, dataClasses_1.applyDataClassDecorator)(
|
|
49144
|
+
evaluator,
|
|
49145
|
+
decoratorNode,
|
|
49146
|
+
originalClassType,
|
|
49147
|
+
dataclassBehaviors,
|
|
49148
|
+
/* callNode */
|
|
49149
|
+
void 0
|
|
49150
|
+
);
|
|
49151
|
+
return inputClassType;
|
|
49152
|
+
}
|
|
49153
|
+
if (decoratorType.overloads.length > 0 && decoratorType.overloads[0].details.builtInName === "deprecated") {
|
|
49154
|
+
originalClassType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
49155
|
+
return inputClassType;
|
|
49156
|
+
}
|
|
49157
|
+
} else if ((0, types_1.isFunction)(decoratorType)) {
|
|
49158
|
+
if (decoratorType.details.builtInName === "final") {
|
|
49159
|
+
originalClassType.details.flags |= 4096;
|
|
49160
|
+
return inputClassType;
|
|
49161
|
+
}
|
|
49162
|
+
if (decoratorType.details.builtInName === "deprecated") {
|
|
49163
|
+
originalClassType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
49164
|
+
return inputClassType;
|
|
49165
|
+
}
|
|
49166
|
+
if (decoratorType.details.builtInName === "runtime_checkable") {
|
|
49167
|
+
originalClassType.details.flags |= 32768;
|
|
49168
|
+
return inputClassType;
|
|
49169
|
+
}
|
|
49170
|
+
let dataclassBehaviors;
|
|
49171
|
+
let callNode;
|
|
49172
|
+
if (decoratorNode.expression.nodeType === 9) {
|
|
49173
|
+
callNode = decoratorNode.expression;
|
|
49174
|
+
const decoratorCallType = evaluator.getTypeOfExpression(
|
|
49175
|
+
callNode.leftExpression,
|
|
49176
|
+
flags | 2
|
|
49177
|
+
/* DoNotSpecialize */
|
|
49178
|
+
).type;
|
|
49179
|
+
dataclassBehaviors = (0, dataClasses_1.getDataclassDecoratorBehaviors)(decoratorCallType);
|
|
49180
|
+
} else {
|
|
49181
|
+
const decoratorType2 = evaluator.getTypeOfExpression(decoratorNode.expression, flags).type;
|
|
49182
|
+
dataclassBehaviors = (0, dataClasses_1.getDataclassDecoratorBehaviors)(decoratorType2);
|
|
49183
|
+
}
|
|
49184
|
+
if (dataclassBehaviors) {
|
|
49185
|
+
(0, dataClasses_1.applyDataClassDecorator)(evaluator, decoratorNode, originalClassType, dataclassBehaviors, callNode);
|
|
49186
|
+
return inputClassType;
|
|
49187
|
+
}
|
|
49188
|
+
}
|
|
49189
|
+
return getTypeOfDecorator(evaluator, decoratorNode, inputClassType);
|
|
49190
|
+
}
|
|
49191
|
+
exports.applyClassDecorator = applyClassDecorator;
|
|
49192
|
+
function getTypeOfDecorator(evaluator, node, functionOrClassType) {
|
|
49193
|
+
let flags = (0, analyzerNodeInfo_1.getFileInfo)(node).isStubFile ? 4 : 0;
|
|
49194
|
+
if (node.expression.nodeType !== 9) {
|
|
49195
|
+
flags |= 2;
|
|
49196
|
+
}
|
|
49197
|
+
const decoratorTypeResult = evaluator.getTypeOfExpression(node.expression, flags);
|
|
49198
|
+
if ((0, types_1.isFunction)(decoratorTypeResult.type) && decoratorTypeResult.type.details.builtInName === "type_check_only") {
|
|
49199
|
+
return functionOrClassType;
|
|
49200
|
+
}
|
|
49201
|
+
if ((0, types_1.isInstantiableClass)(decoratorTypeResult.type) && types_1.ClassType.isBuiltIn(decoratorTypeResult.type, "classmethod") && (0, typeUtils_1.isProperty)(functionOrClassType)) {
|
|
49202
|
+
return functionOrClassType;
|
|
49203
|
+
}
|
|
49204
|
+
const argList = [
|
|
49205
|
+
{
|
|
49206
|
+
argumentCategory: 0,
|
|
49207
|
+
typeResult: { type: functionOrClassType }
|
|
49208
|
+
}
|
|
49209
|
+
];
|
|
49210
|
+
const returnType = evaluator.validateCallArguments(
|
|
49211
|
+
node.expression,
|
|
49212
|
+
argList,
|
|
49213
|
+
decoratorTypeResult,
|
|
49214
|
+
/* typeVarContext */
|
|
49215
|
+
void 0,
|
|
49216
|
+
/* skipUnknownArgCheck */
|
|
49217
|
+
true
|
|
49218
|
+
).returnType || types_1.UnknownType.create();
|
|
49219
|
+
if ((0, types_1.isFunction)(returnType) && !returnType.details.declaredReturnType) {
|
|
49220
|
+
if (!returnType.details.parameters.some((param, index) => {
|
|
49221
|
+
if (!param.name || param.hasDeclaredType) {
|
|
49222
|
+
return true;
|
|
49223
|
+
}
|
|
49224
|
+
if (param.category !== 0) {
|
|
49225
|
+
return false;
|
|
49226
|
+
}
|
|
49227
|
+
return index !== 0 || !param.isTypeInferred;
|
|
49228
|
+
})) {
|
|
49229
|
+
return functionOrClassType;
|
|
49230
|
+
}
|
|
49231
|
+
}
|
|
49232
|
+
if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
|
|
49233
|
+
if ((0, types_1.isFunction)(decoratorTypeResult.type)) {
|
|
49234
|
+
if (!decoratorTypeResult.type.details.parameters.find((param) => param.typeAnnotation !== void 0) && decoratorTypeResult.type.details.declaredReturnType === void 0) {
|
|
49235
|
+
return functionOrClassType;
|
|
49236
|
+
}
|
|
49237
|
+
}
|
|
49238
|
+
}
|
|
49239
|
+
return returnType;
|
|
49240
|
+
}
|
|
49241
|
+
function addOverloadsToFunctionType(evaluator, node, type) {
|
|
49242
|
+
let functionDecl;
|
|
49243
|
+
const decl = (0, analyzerNodeInfo_1.getDeclaration)(node);
|
|
49244
|
+
if (decl) {
|
|
49245
|
+
functionDecl = decl;
|
|
49246
|
+
}
|
|
49247
|
+
const symbolWithScope = evaluator.lookUpSymbolRecursive(
|
|
49248
|
+
node,
|
|
49249
|
+
node.name.value,
|
|
49250
|
+
/* honorCodeFlow */
|
|
49251
|
+
false
|
|
49252
|
+
);
|
|
49253
|
+
if (symbolWithScope) {
|
|
49254
|
+
const decls = symbolWithScope.symbol.getDeclarations();
|
|
49255
|
+
const declIndex = decls.findIndex((decl2) => decl2 === functionDecl);
|
|
49256
|
+
if (declIndex > 0) {
|
|
49257
|
+
for (let i = 0; i < declIndex; i++) {
|
|
49258
|
+
const decl2 = decls[i];
|
|
49259
|
+
if (decl2.type === 5) {
|
|
49260
|
+
evaluator.getTypeOfFunction(decl2.node);
|
|
49261
|
+
}
|
|
49262
|
+
}
|
|
49263
|
+
let overloadedTypes = [];
|
|
49264
|
+
const prevDecl = decls[declIndex - 1];
|
|
49265
|
+
if (prevDecl.type === 5) {
|
|
49266
|
+
const prevDeclDeclTypeInfo = evaluator.getTypeOfFunction(prevDecl.node);
|
|
49267
|
+
if (prevDeclDeclTypeInfo) {
|
|
49268
|
+
if ((0, types_1.isFunction)(prevDeclDeclTypeInfo.decoratedType)) {
|
|
49269
|
+
if (types_1.FunctionType.isOverloaded(prevDeclDeclTypeInfo.decoratedType)) {
|
|
49270
|
+
overloadedTypes.push(prevDeclDeclTypeInfo.decoratedType);
|
|
49271
|
+
}
|
|
49272
|
+
} else if ((0, types_1.isOverloadedFunction)(prevDeclDeclTypeInfo.decoratedType)) {
|
|
49273
|
+
(0, collectionUtils_1.appendArray)(overloadedTypes, prevDeclDeclTypeInfo.decoratedType.overloads);
|
|
49274
|
+
}
|
|
49275
|
+
}
|
|
49276
|
+
}
|
|
49277
|
+
overloadedTypes.push(type);
|
|
49278
|
+
if (overloadedTypes.length === 1) {
|
|
49279
|
+
return overloadedTypes[0];
|
|
49280
|
+
}
|
|
49281
|
+
const implementation = overloadedTypes.find((signature) => !types_1.FunctionType.isOverloaded(signature));
|
|
49282
|
+
if (implementation === null || implementation === void 0 ? void 0 : implementation.details.docString) {
|
|
49283
|
+
overloadedTypes = overloadedTypes.map((overload) => {
|
|
49284
|
+
if (types_1.FunctionType.isOverloaded(overload) && !overload.details.docString) {
|
|
49285
|
+
return types_1.FunctionType.cloneWithDocString(overload, implementation.details.docString);
|
|
49286
|
+
}
|
|
49287
|
+
return overload;
|
|
49288
|
+
});
|
|
49289
|
+
}
|
|
49290
|
+
const newOverload = types_1.OverloadedFunctionType.create(overloadedTypes);
|
|
49291
|
+
const prevOverload = overloadedTypes[overloadedTypes.length - 2];
|
|
49292
|
+
const isPrevOverloadAbstract = types_1.FunctionType.isAbstractMethod(prevOverload);
|
|
49293
|
+
const isCurrentOverloadAbstract = types_1.FunctionType.isAbstractMethod(type);
|
|
49294
|
+
if (isPrevOverloadAbstract !== isCurrentOverloadAbstract) {
|
|
49295
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadAbstractMismatch().format({ name: node.name.value }), node.name);
|
|
49296
|
+
}
|
|
49297
|
+
return newOverload;
|
|
49298
|
+
}
|
|
49299
|
+
}
|
|
49300
|
+
return type;
|
|
49301
|
+
}
|
|
49302
|
+
exports.addOverloadsToFunctionType = addOverloadsToFunctionType;
|
|
49303
|
+
function getCustomDeprecationMessage(decorator) {
|
|
49304
|
+
if (decorator.expression.nodeType === 9 && decorator.expression.arguments.length > 0 && decorator.expression.arguments[0].argumentCategory === 0 && decorator.expression.arguments[0].valueExpression.nodeType === 48 && decorator.expression.arguments[0].valueExpression.strings.length === 1) {
|
|
49305
|
+
return decorator.expression.arguments[0].valueExpression.strings[0].value;
|
|
49306
|
+
}
|
|
49307
|
+
return "";
|
|
49308
|
+
}
|
|
49309
|
+
}
|
|
49310
|
+
});
|
|
49311
|
+
|
|
48367
49312
|
// node_modules/@zzzen/pyright-internal/dist/analyzer/enums.js
|
|
48368
49313
|
var require_enums = __commonJS({
|
|
48369
49314
|
"node_modules/@zzzen/pyright-internal/dist/analyzer/enums.js"(exports) {
|
|
@@ -49074,14 +50019,14 @@ var require_operations = __commonJS({
|
|
|
49074
50019
|
return type && (0, types_1.isNever)(type) ? void 0 : type;
|
|
49075
50020
|
}
|
|
49076
50021
|
exports.validateBinaryOperation = validateBinaryOperation;
|
|
49077
|
-
function getTypeOfBinaryOperation(evaluator, node,
|
|
50022
|
+
function getTypeOfBinaryOperation(evaluator, node, flags, inferenceContext) {
|
|
49078
50023
|
const leftExpression = node.leftExpression;
|
|
49079
50024
|
let rightExpression = node.rightExpression;
|
|
49080
50025
|
let isIncomplete = false;
|
|
49081
50026
|
let typeErrors = false;
|
|
49082
50027
|
if ((0, parseTreeUtils_1.operatorSupportsChaining)(node.operator)) {
|
|
49083
50028
|
if (rightExpression.nodeType === 7 && !rightExpression.parenthesized && (0, parseTreeUtils_1.operatorSupportsChaining)(rightExpression.operator)) {
|
|
49084
|
-
getTypeOfBinaryOperation(evaluator, rightExpression,
|
|
50029
|
+
getTypeOfBinaryOperation(evaluator, rightExpression, flags, inferenceContext);
|
|
49085
50030
|
rightExpression = rightExpression.leftExpression;
|
|
49086
50031
|
}
|
|
49087
50032
|
}
|
|
@@ -49132,13 +50077,13 @@ var require_operations = __commonJS({
|
|
|
49132
50077
|
node.leftExpression,
|
|
49133
50078
|
adjustedLeftType,
|
|
49134
50079
|
flags | 128
|
|
49135
|
-
/*
|
|
50080
|
+
/* ExpectingInstantiableType */
|
|
49136
50081
|
);
|
|
49137
50082
|
adjustedRightType = evaluator.reportMissingTypeArguments(
|
|
49138
50083
|
node.rightExpression,
|
|
49139
50084
|
adjustedRightType,
|
|
49140
50085
|
flags | 128
|
|
49141
|
-
/*
|
|
50086
|
+
/* ExpectingInstantiableType */
|
|
49142
50087
|
);
|
|
49143
50088
|
const newUnion = (0, types_1.combineTypes)([adjustedLeftType, adjustedRightType]);
|
|
49144
50089
|
if ((0, types_1.isUnion)(newUnion)) {
|
|
@@ -49529,407 +50474,6 @@ var require_operations = __commonJS({
|
|
|
49529
50474
|
}
|
|
49530
50475
|
});
|
|
49531
50476
|
|
|
49532
|
-
// node_modules/@zzzen/pyright-internal/dist/analyzer/properties.js
|
|
49533
|
-
var require_properties = __commonJS({
|
|
49534
|
-
"node_modules/@zzzen/pyright-internal/dist/analyzer/properties.js"(exports) {
|
|
49535
|
-
"use strict";
|
|
49536
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49537
|
-
exports.assignProperty = exports.clonePropertyWithDeleter = exports.clonePropertyWithSetter = exports.createProperty = exports.validatePropertyMethod = void 0;
|
|
49538
|
-
var diagnostic_1 = require_diagnostic();
|
|
49539
|
-
var diagnosticRules_1 = require_diagnosticRules();
|
|
49540
|
-
var localize_1 = require_localize();
|
|
49541
|
-
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
49542
|
-
var parseTreeUtils_1 = require_parseTreeUtils();
|
|
49543
|
-
var symbol_1 = require_symbol();
|
|
49544
|
-
var types_1 = require_types();
|
|
49545
|
-
var typeUtils_1 = require_typeUtils();
|
|
49546
|
-
function validatePropertyMethod(evaluator, method2, errorNode) {
|
|
49547
|
-
if (types_1.FunctionType.isStaticMethod(method2)) {
|
|
49548
|
-
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.propertyStaticMethod(), errorNode);
|
|
49549
|
-
}
|
|
49550
|
-
}
|
|
49551
|
-
exports.validatePropertyMethod = validatePropertyMethod;
|
|
49552
|
-
function createProperty(evaluator, decoratorNode, decoratorType, fget) {
|
|
49553
|
-
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(decoratorNode);
|
|
49554
|
-
const typeMetaclass = evaluator.getBuiltInType(decoratorNode, "type");
|
|
49555
|
-
const typeSourceId = types_1.ClassType.isBuiltIn(decoratorType, "property") ? (0, parseTreeUtils_1.getTypeSourceId)(decoratorNode) : decoratorType.details.typeSourceId;
|
|
49556
|
-
const propertyClass = types_1.ClassType.createInstantiable(
|
|
49557
|
-
decoratorType.details.name,
|
|
49558
|
-
(0, parseTreeUtils_1.getClassFullName)(decoratorNode, fileInfo.moduleName, `__property_${fget.details.name}`),
|
|
49559
|
-
fileInfo.moduleName,
|
|
49560
|
-
fileInfo.filePath,
|
|
49561
|
-
2048 | 1,
|
|
49562
|
-
typeSourceId,
|
|
49563
|
-
/* declaredMetaclass */
|
|
49564
|
-
void 0,
|
|
49565
|
-
(0, types_1.isInstantiableClass)(typeMetaclass) ? typeMetaclass : types_1.UnknownType.create()
|
|
49566
|
-
);
|
|
49567
|
-
propertyClass.details.typeVarScopeId = decoratorType.details.typeVarScopeId;
|
|
49568
|
-
const objectType = evaluator.getBuiltInType(decoratorNode, "object");
|
|
49569
|
-
propertyClass.details.baseClasses.push((0, types_1.isInstantiableClass)(objectType) ? objectType : types_1.UnknownType.create());
|
|
49570
|
-
(0, typeUtils_1.computeMroLinearization)(propertyClass);
|
|
49571
|
-
const fields = propertyClass.details.fields;
|
|
49572
|
-
decoratorType.details.fields.forEach((symbol, name) => {
|
|
49573
|
-
const ignoredMethods = ["__get__", "__set__", "__delete__", "fget", "fset", "fdel"];
|
|
49574
|
-
if (!symbol.isIgnoredForProtocolMatch()) {
|
|
49575
|
-
if (!ignoredMethods.some((m) => m === name)) {
|
|
49576
|
-
fields.set(name, symbol);
|
|
49577
|
-
}
|
|
49578
|
-
}
|
|
49579
|
-
});
|
|
49580
|
-
const propertyObject = types_1.ClassType.cloneAsInstance(propertyClass);
|
|
49581
|
-
propertyClass.isAsymmetricDescriptor = false;
|
|
49582
|
-
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
49583
|
-
const fgetSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
49584
|
-
fget,
|
|
49585
|
-
fget.details.flags | 4
|
|
49586
|
-
/* StaticMethod */
|
|
49587
|
-
));
|
|
49588
|
-
fields.set("fget", fgetSymbol);
|
|
49589
|
-
if (types_1.FunctionType.isClassMethod(fget)) {
|
|
49590
|
-
propertyClass.details.flags |= 4194304;
|
|
49591
|
-
}
|
|
49592
|
-
addGetMethodToPropertySymbolTable(evaluator, propertyObject, fget);
|
|
49593
|
-
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
49594
|
-
return propertyObject;
|
|
49595
|
-
}
|
|
49596
|
-
exports.createProperty = createProperty;
|
|
49597
|
-
function clonePropertyWithSetter(evaluator, prop, fset, errorNode) {
|
|
49598
|
-
if (!(0, typeUtils_1.isProperty)(prop)) {
|
|
49599
|
-
return prop;
|
|
49600
|
-
}
|
|
49601
|
-
const classType = prop;
|
|
49602
|
-
const flagsToClone = classType.details.flags;
|
|
49603
|
-
let isAsymmetricDescriptor = !!classType.isAsymmetricDescriptor;
|
|
49604
|
-
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
|
49605
|
-
if (errorNode.parameters.length >= 2) {
|
|
49606
|
-
const typeAnnotation = (0, parseTreeUtils_1.getTypeAnnotationForParameter)(errorNode, 1);
|
|
49607
|
-
if (typeAnnotation) {
|
|
49608
|
-
const fgetType = evaluator.getGetterTypeFromProperty(
|
|
49609
|
-
classType,
|
|
49610
|
-
/* inferTypeIfNeeded */
|
|
49611
|
-
false
|
|
49612
|
-
);
|
|
49613
|
-
if (fgetType && !(0, types_1.isAnyOrUnknown)(fgetType)) {
|
|
49614
|
-
const fsetType = evaluator.getTypeOfAnnotation(typeAnnotation, {
|
|
49615
|
-
associateTypeVarsWithScope: true
|
|
49616
|
-
});
|
|
49617
|
-
if (fileInfo.diagnosticRuleSet.reportPropertyTypeMismatch !== "none") {
|
|
49618
|
-
const diag = new diagnostic_1.DiagnosticAddendum();
|
|
49619
|
-
if (!evaluator.assignType(fgetType, fsetType, diag)) {
|
|
49620
|
-
evaluator.addDiagnostic(fileInfo.diagnosticRuleSet.reportPropertyTypeMismatch, diagnosticRules_1.DiagnosticRule.reportPropertyTypeMismatch, localize_1.Localizer.Diagnostic.setterGetterTypeMismatch() + diag.getString(), typeAnnotation);
|
|
49621
|
-
}
|
|
49622
|
-
}
|
|
49623
|
-
if (!(0, types_1.isTypeSame)(fgetType, fsetType)) {
|
|
49624
|
-
isAsymmetricDescriptor = true;
|
|
49625
|
-
}
|
|
49626
|
-
}
|
|
49627
|
-
}
|
|
49628
|
-
}
|
|
49629
|
-
const propertyClass = types_1.ClassType.createInstantiable(classType.details.name, classType.details.fullName, classType.details.moduleName, (0, analyzerNodeInfo_1.getFileInfo)(errorNode).filePath, flagsToClone, classType.details.typeSourceId, classType.details.declaredMetaclass, classType.details.effectiveMetaclass);
|
|
49630
|
-
propertyClass.details.typeVarScopeId = classType.details.typeVarScopeId;
|
|
49631
|
-
const objectType = evaluator.getBuiltInType(errorNode, "object");
|
|
49632
|
-
propertyClass.details.baseClasses.push((0, types_1.isInstantiableClass)(objectType) ? objectType : types_1.UnknownType.create());
|
|
49633
|
-
(0, typeUtils_1.computeMroLinearization)(propertyClass);
|
|
49634
|
-
propertyClass.isAsymmetricDescriptor = isAsymmetricDescriptor;
|
|
49635
|
-
const propertyObject = types_1.ClassType.cloneAsInstance(propertyClass);
|
|
49636
|
-
const fields = propertyClass.details.fields;
|
|
49637
|
-
classType.details.fields.forEach((symbol, name) => {
|
|
49638
|
-
if (!symbol.isIgnoredForProtocolMatch()) {
|
|
49639
|
-
fields.set(name, symbol);
|
|
49640
|
-
}
|
|
49641
|
-
});
|
|
49642
|
-
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
49643
|
-
const fsetSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
49644
|
-
fset,
|
|
49645
|
-
fset.details.flags | 4
|
|
49646
|
-
/* StaticMethod */
|
|
49647
|
-
));
|
|
49648
|
-
fields.set("fset", fsetSymbol);
|
|
49649
|
-
addSetMethodToPropertySymbolTable(evaluator, propertyObject, fset);
|
|
49650
|
-
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
49651
|
-
return propertyObject;
|
|
49652
|
-
}
|
|
49653
|
-
exports.clonePropertyWithSetter = clonePropertyWithSetter;
|
|
49654
|
-
function clonePropertyWithDeleter(evaluator, prop, fdel, errorNode) {
|
|
49655
|
-
var _a;
|
|
49656
|
-
if (!(0, typeUtils_1.isProperty)(prop)) {
|
|
49657
|
-
return prop;
|
|
49658
|
-
}
|
|
49659
|
-
const classType = prop;
|
|
49660
|
-
const propertyClass = types_1.ClassType.createInstantiable(classType.details.name, classType.details.fullName, classType.details.moduleName, (0, analyzerNodeInfo_1.getFileInfo)(errorNode).filePath, classType.details.flags, classType.details.typeSourceId, classType.details.declaredMetaclass, classType.details.effectiveMetaclass);
|
|
49661
|
-
propertyClass.details.typeVarScopeId = classType.details.typeVarScopeId;
|
|
49662
|
-
const objectType = evaluator.getBuiltInType(errorNode, "object");
|
|
49663
|
-
propertyClass.details.baseClasses.push((0, types_1.isInstantiableClass)(objectType) ? objectType : types_1.UnknownType.create());
|
|
49664
|
-
(0, typeUtils_1.computeMroLinearization)(propertyClass);
|
|
49665
|
-
const propertyObject = types_1.ClassType.cloneAsInstance(propertyClass);
|
|
49666
|
-
propertyClass.isAsymmetricDescriptor = (_a = classType.isAsymmetricDescriptor) !== null && _a !== void 0 ? _a : false;
|
|
49667
|
-
const fields = propertyClass.details.fields;
|
|
49668
|
-
classType.details.fields.forEach((symbol, name) => {
|
|
49669
|
-
if (!symbol.isIgnoredForProtocolMatch()) {
|
|
49670
|
-
fields.set(name, symbol);
|
|
49671
|
-
}
|
|
49672
|
-
});
|
|
49673
|
-
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
49674
|
-
const fdelSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
49675
|
-
fdel,
|
|
49676
|
-
fdel.details.flags | 4
|
|
49677
|
-
/* StaticMethod */
|
|
49678
|
-
));
|
|
49679
|
-
fields.set("fdel", fdelSymbol);
|
|
49680
|
-
addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdel);
|
|
49681
|
-
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
49682
|
-
return propertyObject;
|
|
49683
|
-
}
|
|
49684
|
-
exports.clonePropertyWithDeleter = clonePropertyWithDeleter;
|
|
49685
|
-
function addGetMethodToPropertySymbolTable(evaluator, propertyObject, fget) {
|
|
49686
|
-
const fields = propertyObject.details.fields;
|
|
49687
|
-
const getFunction1 = types_1.FunctionType.createSynthesizedInstance(
|
|
49688
|
-
"__get__",
|
|
49689
|
-
256
|
|
49690
|
-
/* Overloaded */
|
|
49691
|
-
);
|
|
49692
|
-
types_1.FunctionType.addParameter(getFunction1, {
|
|
49693
|
-
category: 0,
|
|
49694
|
-
name: "self",
|
|
49695
|
-
type: types_1.AnyType.create(),
|
|
49696
|
-
hasDeclaredType: true
|
|
49697
|
-
});
|
|
49698
|
-
types_1.FunctionType.addParameter(getFunction1, {
|
|
49699
|
-
category: 0,
|
|
49700
|
-
name: "obj",
|
|
49701
|
-
type: types_1.NoneType.createInstance(),
|
|
49702
|
-
hasDeclaredType: true
|
|
49703
|
-
});
|
|
49704
|
-
types_1.FunctionType.addParameter(getFunction1, {
|
|
49705
|
-
category: 0,
|
|
49706
|
-
name: "objtype",
|
|
49707
|
-
type: types_1.AnyType.create(),
|
|
49708
|
-
hasDeclaredType: true,
|
|
49709
|
-
hasDefault: true,
|
|
49710
|
-
defaultType: types_1.AnyType.create()
|
|
49711
|
-
});
|
|
49712
|
-
getFunction1.details.declaredReturnType = types_1.FunctionType.isClassMethod(fget) ? types_1.FunctionType.getSpecializedReturnType(fget) : propertyObject;
|
|
49713
|
-
getFunction1.details.declaration = fget.details.declaration;
|
|
49714
|
-
getFunction1.details.typeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(fget);
|
|
49715
|
-
const getFunction2 = types_1.FunctionType.createSynthesizedInstance(
|
|
49716
|
-
"__get__",
|
|
49717
|
-
256
|
|
49718
|
-
/* Overloaded */
|
|
49719
|
-
);
|
|
49720
|
-
types_1.FunctionType.addParameter(getFunction2, {
|
|
49721
|
-
category: 0,
|
|
49722
|
-
name: "self",
|
|
49723
|
-
type: types_1.AnyType.create(),
|
|
49724
|
-
hasDeclaredType: true
|
|
49725
|
-
});
|
|
49726
|
-
const objType = fget.details.parameters.length > 0 ? fget.details.parameters[0].type : types_1.AnyType.create();
|
|
49727
|
-
types_1.FunctionType.addParameter(getFunction2, {
|
|
49728
|
-
category: 0,
|
|
49729
|
-
name: "obj",
|
|
49730
|
-
type: objType,
|
|
49731
|
-
hasDeclaredType: true
|
|
49732
|
-
});
|
|
49733
|
-
types_1.FunctionType.addParameter(getFunction2, {
|
|
49734
|
-
category: 0,
|
|
49735
|
-
name: "objtype",
|
|
49736
|
-
type: types_1.AnyType.create(),
|
|
49737
|
-
hasDeclaredType: true,
|
|
49738
|
-
hasDefault: true,
|
|
49739
|
-
defaultType: types_1.AnyType.create()
|
|
49740
|
-
});
|
|
49741
|
-
getFunction2.details.declaredReturnType = types_1.FunctionType.getSpecializedReturnType(fget);
|
|
49742
|
-
getFunction2.details.declaration = fget.details.declaration;
|
|
49743
|
-
getFunction2.details.typeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(fget);
|
|
49744
|
-
const getFunctionOverload = types_1.OverloadedFunctionType.create([getFunction2, getFunction1]);
|
|
49745
|
-
const getSymbol = symbol_1.Symbol.createWithType(4, getFunctionOverload);
|
|
49746
|
-
fields.set("__get__", getSymbol);
|
|
49747
|
-
}
|
|
49748
|
-
function addSetMethodToPropertySymbolTable(evaluator, propertyObject, fset) {
|
|
49749
|
-
const fields = propertyObject.details.fields;
|
|
49750
|
-
const setFunction = types_1.FunctionType.createSynthesizedInstance("__set__");
|
|
49751
|
-
types_1.FunctionType.addParameter(setFunction, {
|
|
49752
|
-
category: 0,
|
|
49753
|
-
name: "self",
|
|
49754
|
-
type: types_1.AnyType.create(),
|
|
49755
|
-
hasDeclaredType: true
|
|
49756
|
-
});
|
|
49757
|
-
let objType = fset.details.parameters.length > 0 ? fset.details.parameters[0].type : types_1.AnyType.create();
|
|
49758
|
-
if ((0, types_1.isTypeVar)(objType) && objType.details.isSynthesizedSelf) {
|
|
49759
|
-
objType = evaluator.makeTopLevelTypeVarsConcrete(objType);
|
|
49760
|
-
}
|
|
49761
|
-
types_1.FunctionType.addParameter(setFunction, {
|
|
49762
|
-
category: 0,
|
|
49763
|
-
name: "obj",
|
|
49764
|
-
type: (0, types_1.combineTypes)([objType, types_1.NoneType.createInstance()]),
|
|
49765
|
-
hasDeclaredType: true
|
|
49766
|
-
});
|
|
49767
|
-
setFunction.details.declaredReturnType = types_1.NoneType.createInstance();
|
|
49768
|
-
setFunction.details.typeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(fset);
|
|
49769
|
-
let setParamType = types_1.UnknownType.create();
|
|
49770
|
-
if (fset.details.parameters.length >= 2 && fset.details.parameters[1].category === 0 && fset.details.parameters[1].name) {
|
|
49771
|
-
setParamType = fset.details.parameters[1].type;
|
|
49772
|
-
}
|
|
49773
|
-
types_1.FunctionType.addParameter(setFunction, {
|
|
49774
|
-
category: 0,
|
|
49775
|
-
name: "value",
|
|
49776
|
-
type: setParamType,
|
|
49777
|
-
hasDeclaredType: true
|
|
49778
|
-
});
|
|
49779
|
-
const setSymbol = symbol_1.Symbol.createWithType(4, setFunction);
|
|
49780
|
-
fields.set("__set__", setSymbol);
|
|
49781
|
-
}
|
|
49782
|
-
function addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdel) {
|
|
49783
|
-
const fields = propertyObject.details.fields;
|
|
49784
|
-
const delFunction = types_1.FunctionType.createSynthesizedInstance("__delete__");
|
|
49785
|
-
types_1.FunctionType.addParameter(delFunction, {
|
|
49786
|
-
category: 0,
|
|
49787
|
-
name: "self",
|
|
49788
|
-
type: types_1.AnyType.create(),
|
|
49789
|
-
hasDeclaredType: true
|
|
49790
|
-
});
|
|
49791
|
-
delFunction.details.typeVarScopeId = (0, typeUtils_1.getTypeVarScopeId)(fdel);
|
|
49792
|
-
let objType = fdel.details.parameters.length > 0 ? fdel.details.parameters[0].type : types_1.AnyType.create();
|
|
49793
|
-
if ((0, types_1.isTypeVar)(objType) && objType.details.isSynthesizedSelf) {
|
|
49794
|
-
objType = evaluator.makeTopLevelTypeVarsConcrete(objType);
|
|
49795
|
-
}
|
|
49796
|
-
types_1.FunctionType.addParameter(delFunction, {
|
|
49797
|
-
category: 0,
|
|
49798
|
-
name: "obj",
|
|
49799
|
-
type: (0, types_1.combineTypes)([objType, types_1.NoneType.createInstance()]),
|
|
49800
|
-
hasDeclaredType: true
|
|
49801
|
-
});
|
|
49802
|
-
delFunction.details.declaredReturnType = types_1.NoneType.createInstance();
|
|
49803
|
-
const delSymbol = symbol_1.Symbol.createWithType(4, delFunction);
|
|
49804
|
-
fields.set("__delete__", delSymbol);
|
|
49805
|
-
}
|
|
49806
|
-
function updateGetSetDelMethodForClonedProperty(evaluator, propertyObject) {
|
|
49807
|
-
const fields = propertyObject.details.fields;
|
|
49808
|
-
const fgetSymbol = fields.get("fget");
|
|
49809
|
-
const fgetType = fgetSymbol === null || fgetSymbol === void 0 ? void 0 : fgetSymbol.getSynthesizedType();
|
|
49810
|
-
if (fgetType && (0, types_1.isFunction)(fgetType)) {
|
|
49811
|
-
addGetMethodToPropertySymbolTable(evaluator, propertyObject, fgetType);
|
|
49812
|
-
}
|
|
49813
|
-
const fsetSymbol = fields.get("fset");
|
|
49814
|
-
const fsetType = fsetSymbol === null || fsetSymbol === void 0 ? void 0 : fsetSymbol.getSynthesizedType();
|
|
49815
|
-
if (fsetType && (0, types_1.isFunction)(fsetType)) {
|
|
49816
|
-
addSetMethodToPropertySymbolTable(evaluator, propertyObject, fsetType);
|
|
49817
|
-
}
|
|
49818
|
-
const fdelSymbol = fields.get("fdel");
|
|
49819
|
-
const fdelType = fdelSymbol === null || fdelSymbol === void 0 ? void 0 : fdelSymbol.getSynthesizedType();
|
|
49820
|
-
if (fdelType && (0, types_1.isFunction)(fdelType)) {
|
|
49821
|
-
addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdelType);
|
|
49822
|
-
}
|
|
49823
|
-
}
|
|
49824
|
-
function addDecoratorMethodsToPropertySymbolTable(propertyObject) {
|
|
49825
|
-
const fields = propertyObject.details.fields;
|
|
49826
|
-
["getter", "setter", "deleter"].forEach((accessorName) => {
|
|
49827
|
-
const accessorFunction = types_1.FunctionType.createSynthesizedInstance(accessorName);
|
|
49828
|
-
types_1.FunctionType.addParameter(accessorFunction, {
|
|
49829
|
-
category: 0,
|
|
49830
|
-
name: "self",
|
|
49831
|
-
type: types_1.AnyType.create(),
|
|
49832
|
-
hasDeclaredType: true
|
|
49833
|
-
});
|
|
49834
|
-
types_1.FunctionType.addParameter(accessorFunction, {
|
|
49835
|
-
category: 0,
|
|
49836
|
-
name: "accessor",
|
|
49837
|
-
type: types_1.AnyType.create(),
|
|
49838
|
-
hasDeclaredType: true
|
|
49839
|
-
});
|
|
49840
|
-
accessorFunction.details.declaredReturnType = propertyObject;
|
|
49841
|
-
const accessorSymbol = symbol_1.Symbol.createWithType(4, accessorFunction);
|
|
49842
|
-
fields.set(accessorName, accessorSymbol);
|
|
49843
|
-
});
|
|
49844
|
-
}
|
|
49845
|
-
function assignProperty(evaluator, destPropertyType, srcPropertyType, destClass, srcClass, diag, typeVarContext, selfTypeVarContext, recursionCount = 0) {
|
|
49846
|
-
const srcObjectToBind = types_1.ClassType.cloneAsInstance(srcClass);
|
|
49847
|
-
const destObjectToBind = types_1.ClassType.cloneAsInstance(destClass);
|
|
49848
|
-
let isAssignable = true;
|
|
49849
|
-
const accessors = [
|
|
49850
|
-
{
|
|
49851
|
-
name: "fget",
|
|
49852
|
-
missingDiagMsg: localize_1.Localizer.DiagnosticAddendum.missingGetter,
|
|
49853
|
-
incompatibleDiagMsg: localize_1.Localizer.DiagnosticAddendum.incompatibleGetter
|
|
49854
|
-
},
|
|
49855
|
-
{
|
|
49856
|
-
name: "fset",
|
|
49857
|
-
missingDiagMsg: localize_1.Localizer.DiagnosticAddendum.missingSetter,
|
|
49858
|
-
incompatibleDiagMsg: localize_1.Localizer.DiagnosticAddendum.incompatibleSetter
|
|
49859
|
-
},
|
|
49860
|
-
{
|
|
49861
|
-
name: "fdel",
|
|
49862
|
-
missingDiagMsg: localize_1.Localizer.DiagnosticAddendum.missingDeleter,
|
|
49863
|
-
incompatibleDiagMsg: localize_1.Localizer.DiagnosticAddendum.incompatibleDeleter
|
|
49864
|
-
}
|
|
49865
|
-
];
|
|
49866
|
-
accessors.forEach((accessorInfo) => {
|
|
49867
|
-
var _a, _b;
|
|
49868
|
-
const destAccessSymbol = destPropertyType.details.fields.get(accessorInfo.name);
|
|
49869
|
-
let destAccessType = destAccessSymbol ? (_a = evaluator.getDeclaredTypeOfSymbol(destAccessSymbol)) === null || _a === void 0 ? void 0 : _a.type : void 0;
|
|
49870
|
-
if (destAccessType && (0, types_1.isFunction)(destAccessType)) {
|
|
49871
|
-
const srcAccessSymbol = srcPropertyType.details.fields.get(accessorInfo.name);
|
|
49872
|
-
let srcAccessType = srcAccessSymbol ? (_b = evaluator.getDeclaredTypeOfSymbol(srcAccessSymbol)) === null || _b === void 0 ? void 0 : _b.type : void 0;
|
|
49873
|
-
if (!srcAccessType || !(0, types_1.isFunction)(srcAccessType)) {
|
|
49874
|
-
diag === null || diag === void 0 ? void 0 : diag.addMessage(accessorInfo.missingDiagMsg());
|
|
49875
|
-
isAssignable = false;
|
|
49876
|
-
return;
|
|
49877
|
-
}
|
|
49878
|
-
evaluator.inferReturnTypeIfNecessary(srcAccessType);
|
|
49879
|
-
srcAccessType = (0, typeUtils_1.partiallySpecializeType)(srcAccessType, srcClass);
|
|
49880
|
-
evaluator.inferReturnTypeIfNecessary(destAccessType);
|
|
49881
|
-
destAccessType = (0, typeUtils_1.partiallySpecializeType)(destAccessType, destClass);
|
|
49882
|
-
if (selfTypeVarContext) {
|
|
49883
|
-
destAccessType = (0, typeUtils_1.applySolvedTypeVars)(destAccessType, selfTypeVarContext);
|
|
49884
|
-
}
|
|
49885
|
-
destAccessType = types_1.FunctionType.cloneWithNewFlags(
|
|
49886
|
-
destAccessType,
|
|
49887
|
-
destAccessType.details.flags & ~4
|
|
49888
|
-
/* StaticMethod */
|
|
49889
|
-
);
|
|
49890
|
-
srcAccessType = types_1.FunctionType.cloneWithNewFlags(
|
|
49891
|
-
srcAccessType,
|
|
49892
|
-
srcAccessType.details.flags & ~4
|
|
49893
|
-
/* StaticMethod */
|
|
49894
|
-
);
|
|
49895
|
-
const boundDestAccessType = evaluator.bindFunctionToClassOrObject(
|
|
49896
|
-
destObjectToBind,
|
|
49897
|
-
destAccessType,
|
|
49898
|
-
/* memberClass */
|
|
49899
|
-
void 0,
|
|
49900
|
-
/* errorNode */
|
|
49901
|
-
void 0,
|
|
49902
|
-
recursionCount
|
|
49903
|
-
);
|
|
49904
|
-
const boundSrcAccessType = evaluator.bindFunctionToClassOrObject(
|
|
49905
|
-
srcObjectToBind,
|
|
49906
|
-
srcAccessType,
|
|
49907
|
-
/* memberClass */
|
|
49908
|
-
void 0,
|
|
49909
|
-
/* errorNode */
|
|
49910
|
-
void 0,
|
|
49911
|
-
recursionCount
|
|
49912
|
-
);
|
|
49913
|
-
if (!boundDestAccessType || !boundSrcAccessType || !evaluator.assignType(
|
|
49914
|
-
boundDestAccessType,
|
|
49915
|
-
boundSrcAccessType,
|
|
49916
|
-
diag,
|
|
49917
|
-
typeVarContext,
|
|
49918
|
-
/* srcTypeVarContext */
|
|
49919
|
-
void 0,
|
|
49920
|
-
0,
|
|
49921
|
-
recursionCount
|
|
49922
|
-
)) {
|
|
49923
|
-
isAssignable = false;
|
|
49924
|
-
}
|
|
49925
|
-
}
|
|
49926
|
-
});
|
|
49927
|
-
return isAssignable;
|
|
49928
|
-
}
|
|
49929
|
-
exports.assignProperty = assignProperty;
|
|
49930
|
-
}
|
|
49931
|
-
});
|
|
49932
|
-
|
|
49933
50477
|
// node_modules/@zzzen/pyright-internal/dist/analyzer/protocols.js
|
|
49934
50478
|
var require_protocols = __commonJS({
|
|
49935
50479
|
"node_modules/@zzzen/pyright-internal/dist/analyzer/protocols.js"(exports) {
|
|
@@ -50200,7 +50744,7 @@ var require_protocols = __commonJS({
|
|
|
50200
50744
|
);
|
|
50201
50745
|
const specializedProtocolType = (0, typeUtils_1.applySolvedTypeVars)(genericProtocolType, protocolTypeVarContext);
|
|
50202
50746
|
if (destType.typeArguments) {
|
|
50203
|
-
if (!evaluator.
|
|
50747
|
+
if (!evaluator.assignTypeArguments(destType, specializedProtocolType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
|
|
50204
50748
|
typesAreConsistent = false;
|
|
50205
50749
|
}
|
|
50206
50750
|
} else if (destTypeVarContext && !destTypeVarContext.isLocked()) {
|
|
@@ -50285,7 +50829,7 @@ var require_protocols = __commonJS({
|
|
|
50285
50829
|
false
|
|
50286
50830
|
);
|
|
50287
50831
|
const specializedProtocolType = (0, typeUtils_1.applySolvedTypeVars)(genericProtocolType, protocolTypeVarContext);
|
|
50288
|
-
if (!evaluator.
|
|
50832
|
+
if (!evaluator.assignTypeArguments(
|
|
50289
50833
|
destType,
|
|
50290
50834
|
specializedProtocolType,
|
|
50291
50835
|
diag,
|
|
@@ -50562,6 +51106,7 @@ var require_typePrinter = __commonJS({
|
|
|
50562
51106
|
PrintTypeFlags2[PrintTypeFlags2["PythonSyntax"] = 256] = "PythonSyntax";
|
|
50563
51107
|
PrintTypeFlags2[PrintTypeFlags2["UseTypingUnpack"] = 512] = "UseTypingUnpack";
|
|
50564
51108
|
PrintTypeFlags2[PrintTypeFlags2["ExpandTypedDictArgs"] = 1024] = "ExpandTypedDictArgs";
|
|
51109
|
+
PrintTypeFlags2[PrintTypeFlags2["PrintTypeVarVariance"] = 2048] = "PrintTypeVarVariance";
|
|
50565
51110
|
})(PrintTypeFlags = exports.PrintTypeFlags || (exports.PrintTypeFlags = {}));
|
|
50566
51111
|
function printType(type, printTypeFlags, returnTypeCallback) {
|
|
50567
51112
|
const uniqueNameMap = new UniqueNameMap(printTypeFlags, returnTypeCallback);
|
|
@@ -50765,8 +51310,8 @@ var require_typePrinter = __commonJS({
|
|
|
50765
51310
|
}
|
|
50766
51311
|
case 5: {
|
|
50767
51312
|
if (types_1.TypeBase.isInstantiable(type)) {
|
|
50768
|
-
const typeString = printFunctionType(types_1.
|
|
50769
|
-
return `
|
|
51313
|
+
const typeString = printFunctionType(types_1.FunctionType.cloneAsInstance(type), printTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
|
51314
|
+
return `type[${typeString}]`;
|
|
50770
51315
|
}
|
|
50771
51316
|
return printFunctionType(type, originalPrintTypeFlags, returnTypeCallback, uniqueNameMap, recursionTypes, recursionCount);
|
|
50772
51317
|
}
|
|
@@ -50851,7 +51396,7 @@ var require_typePrinter = __commonJS({
|
|
|
50851
51396
|
if (literalClassStrings.size > 0) {
|
|
50852
51397
|
const literalStrings = [];
|
|
50853
51398
|
literalClassStrings.forEach((s) => literalStrings.push(s));
|
|
50854
|
-
dedupedSubtypeStrings.push(`
|
|
51399
|
+
dedupedSubtypeStrings.push(`type[Literal[${literalStrings.join(", ")}]]`);
|
|
50855
51400
|
}
|
|
50856
51401
|
if (dedupedSubtypeStrings.length === 1) {
|
|
50857
51402
|
return dedupedSubtypeStrings[0];
|
|
@@ -50903,7 +51448,13 @@ var require_typePrinter = __commonJS({
|
|
|
50903
51448
|
typeVarName = `Union[${typeVarName}]`;
|
|
50904
51449
|
}
|
|
50905
51450
|
if (types_1.TypeBase.isInstantiable(type)) {
|
|
50906
|
-
|
|
51451
|
+
typeVarName = `${_printNestedInstantiable(type, typeVarName)}`;
|
|
51452
|
+
}
|
|
51453
|
+
if (!type.details.isVariadic && (printTypeFlags & 2048) !== 0) {
|
|
51454
|
+
const varianceText = _getTypeVarVarianceText(type);
|
|
51455
|
+
if (varianceText) {
|
|
51456
|
+
typeVarName = `${typeVarName} (${varianceText})`;
|
|
51457
|
+
}
|
|
50907
51458
|
}
|
|
50908
51459
|
return typeVarName;
|
|
50909
51460
|
}
|
|
@@ -51186,7 +51737,7 @@ var require_typePrinter = __commonJS({
|
|
|
51186
51737
|
var _a;
|
|
51187
51738
|
const nestedTypes = ((_a = type.instantiableNestingLevel) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
51188
51739
|
for (let nestLevel = 0; nestLevel < nestedTypes; nestLevel++) {
|
|
51189
|
-
textToWrap = `
|
|
51740
|
+
textToWrap = `type[${textToWrap}]`;
|
|
51190
51741
|
}
|
|
51191
51742
|
return textToWrap;
|
|
51192
51743
|
}
|
|
@@ -51196,6 +51747,20 @@ var require_typePrinter = __commonJS({
|
|
|
51196
51747
|
}
|
|
51197
51748
|
return types_1.TypeVarType.getReadableName(type);
|
|
51198
51749
|
}
|
|
51750
|
+
function _getTypeVarVarianceText(type) {
|
|
51751
|
+
var _a;
|
|
51752
|
+
const computedVariance = (_a = type.computedVariance) !== null && _a !== void 0 ? _a : type.details.declaredVariance;
|
|
51753
|
+
if (computedVariance === 2) {
|
|
51754
|
+
return "invariant";
|
|
51755
|
+
}
|
|
51756
|
+
if (computedVariance === 3) {
|
|
51757
|
+
return "covariant";
|
|
51758
|
+
}
|
|
51759
|
+
if (computedVariance === 4) {
|
|
51760
|
+
return "contravariant";
|
|
51761
|
+
}
|
|
51762
|
+
return "";
|
|
51763
|
+
}
|
|
51199
51764
|
var UniqueNameMap = class {
|
|
51200
51765
|
constructor(_printTypeFlags, _returnTypeCallback) {
|
|
51201
51766
|
this._printTypeFlags = _printTypeFlags;
|
|
@@ -51368,6 +51933,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
51368
51933
|
var constructors_1 = require_constructors();
|
|
51369
51934
|
var dataClasses_1 = require_dataClasses();
|
|
51370
51935
|
var declarationUtils_1 = require_declarationUtils();
|
|
51936
|
+
var decorators_1 = require_decorators();
|
|
51371
51937
|
var enums_1 = require_enums();
|
|
51372
51938
|
var functionTransform_1 = require_functionTransform();
|
|
51373
51939
|
var namedTuples_1 = require_namedTuples();
|
|
@@ -51606,10 +52172,29 @@ var require_typeEvaluator = __commonJS({
|
|
|
51606
52172
|
return void 0;
|
|
51607
52173
|
}
|
|
51608
52174
|
function getType(node) {
|
|
51609
|
-
var _a;
|
|
51610
|
-
|
|
52175
|
+
var _a, _b;
|
|
52176
|
+
let type = (_a = evaluateTypeForSubnode(node, () => {
|
|
51611
52177
|
evaluateTypesForExpressionInContext(node);
|
|
51612
52178
|
})) === null || _a === void 0 ? void 0 : _a.type;
|
|
52179
|
+
if (type && (0, types_1.isTypeVar)(type) && type.details.declaredVariance === 0) {
|
|
52180
|
+
const typeVarType = type;
|
|
52181
|
+
const typeParamListNode = ParseTreeUtils.getParentNodeOfType(
|
|
52182
|
+
node,
|
|
52183
|
+
76
|
|
52184
|
+
/* TypeParameterList */
|
|
52185
|
+
);
|
|
52186
|
+
if (((_b = typeParamListNode === null || typeParamListNode === void 0 ? void 0 : typeParamListNode.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 10) {
|
|
52187
|
+
const classTypeResult = getTypeOfClass(typeParamListNode.parent);
|
|
52188
|
+
if (classTypeResult) {
|
|
52189
|
+
inferTypeParameterVarianceForClass(classTypeResult.classType);
|
|
52190
|
+
const typeParam = classTypeResult.classType.details.typeParameters.find((param) => (0, types_1.isTypeSame)(param, typeVarType, { ignoreTypeFlags: true }));
|
|
52191
|
+
if (typeParam) {
|
|
52192
|
+
type = types_1.TypeBase.isInstance(type) ? types_1.TypeVarType.cloneAsInstance(typeParam) : typeParam;
|
|
52193
|
+
}
|
|
52194
|
+
}
|
|
52195
|
+
}
|
|
52196
|
+
}
|
|
52197
|
+
return type;
|
|
51613
52198
|
}
|
|
51614
52199
|
function getTypeResult(node) {
|
|
51615
52200
|
return evaluateTypeForSubnode(node, () => {
|
|
@@ -51671,7 +52256,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
51671
52256
|
}
|
|
51672
52257
|
}
|
|
51673
52258
|
function getTypeOfExpression(node, flags = 0, inferenceContext) {
|
|
51674
|
-
var _a;
|
|
51675
52259
|
const cacheEntry = readTypeCacheEntry(node);
|
|
51676
52260
|
if (cacheEntry && (!cacheEntry.typeResult.isIncomplete || cacheEntry.incompleteGenerationCount === incompleteGenerationCount)) {
|
|
51677
52261
|
if (printExpressionTypes) {
|
|
@@ -51697,7 +52281,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
51697
52281
|
}
|
|
51698
52282
|
initializedBasicTypes(node);
|
|
51699
52283
|
let typeResult;
|
|
51700
|
-
let
|
|
52284
|
+
let expectingInstantiable = (flags & 128) !== 0;
|
|
51701
52285
|
switch (node.nodeType) {
|
|
51702
52286
|
case 38: {
|
|
51703
52287
|
typeResult = getTypeOfName(node, flags);
|
|
@@ -51712,11 +52296,11 @@ var require_typeEvaluator = __commonJS({
|
|
|
51712
52296
|
break;
|
|
51713
52297
|
}
|
|
51714
52298
|
case 9: {
|
|
51715
|
-
typeResult = getTypeOfCall(node,
|
|
52299
|
+
typeResult = getTypeOfCall(node, flags, inferenceContext);
|
|
51716
52300
|
break;
|
|
51717
52301
|
}
|
|
51718
52302
|
case 52: {
|
|
51719
|
-
typeResult = getTypeOfTuple(node,
|
|
52303
|
+
typeResult = getTypeOfTuple(node, flags, inferenceContext);
|
|
51720
52304
|
break;
|
|
51721
52305
|
}
|
|
51722
52306
|
case 11: {
|
|
@@ -51726,7 +52310,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
51726
52310
|
case 48: {
|
|
51727
52311
|
const isExpectingType = (flags & 8) !== 0 && !isAnnotationLiteralValue(node);
|
|
51728
52312
|
if (isExpectingType) {
|
|
51729
|
-
|
|
52313
|
+
expectingInstantiable = false;
|
|
51730
52314
|
}
|
|
51731
52315
|
typeResult = getTypeOfStringList(node, flags, isExpectingType);
|
|
51732
52316
|
break;
|
|
@@ -51744,7 +52328,11 @@ var require_typeEvaluator = __commonJS({
|
|
|
51744
52328
|
break;
|
|
51745
52329
|
}
|
|
51746
52330
|
case 7: {
|
|
51747
|
-
|
|
52331
|
+
let effectiveFlags = flags;
|
|
52332
|
+
if (expectingInstantiable && node.operator !== 6) {
|
|
52333
|
+
effectiveFlags &= ~128;
|
|
52334
|
+
}
|
|
52335
|
+
typeResult = (0, operations_1.getTypeOfBinaryOperation)(evaluatorInterface, node, effectiveFlags, inferenceContext);
|
|
51748
52336
|
break;
|
|
51749
52337
|
}
|
|
51750
52338
|
case 5: {
|
|
@@ -51846,21 +52434,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
51846
52434
|
if (!typeResult) {
|
|
51847
52435
|
(0, debug_1.fail)(`Unhandled expression type '${ParseTreeUtils.printExpression(node)}'`);
|
|
51848
52436
|
}
|
|
51849
|
-
if (
|
|
51850
|
-
|
|
51851
|
-
if ((0, types_1.isVariadicTypeVar)(typeResult.type) && !typeResult.type.isVariadicInUnion) {
|
|
51852
|
-
addError(localize_1.Localizer.Diagnostic.typeVarTupleContext(), node);
|
|
51853
|
-
typeResult.type = types_1.UnknownType.create();
|
|
51854
|
-
}
|
|
51855
|
-
}
|
|
51856
|
-
if (!(0, typeUtils_1.isEffectivelyInstantiable)(typeResult.type)) {
|
|
51857
|
-
const isEmptyVariadic = (0, types_1.isClassInstance)(typeResult.type) && types_1.ClassType.isTupleClass(typeResult.type) && ((_a = typeResult.type.tupleTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
51858
|
-
if (!isEmptyVariadic) {
|
|
51859
|
-
addExpectedClassDiagnostic(typeResult.type, node);
|
|
51860
|
-
typeResult.type = types_1.UnknownType.create();
|
|
51861
|
-
typeResult.typeErrors = true;
|
|
51862
|
-
}
|
|
51863
|
-
}
|
|
52437
|
+
if (expectingInstantiable) {
|
|
52438
|
+
validateTypeIsInstantiable(typeResult, flags, node);
|
|
51864
52439
|
}
|
|
51865
52440
|
writeTypeCache(
|
|
51866
52441
|
node,
|
|
@@ -51900,6 +52475,26 @@ var require_typeEvaluator = __commonJS({
|
|
|
51900
52475
|
}
|
|
51901
52476
|
return typeResult;
|
|
51902
52477
|
}
|
|
52478
|
+
function validateTypeIsInstantiable(typeResult, flags, node) {
|
|
52479
|
+
var _a;
|
|
52480
|
+
if (typeResult.isIncomplete) {
|
|
52481
|
+
return;
|
|
52482
|
+
}
|
|
52483
|
+
if (flags & 64) {
|
|
52484
|
+
if ((0, types_1.isVariadicTypeVar)(typeResult.type) && !typeResult.type.isVariadicInUnion) {
|
|
52485
|
+
addError(localize_1.Localizer.Diagnostic.typeVarTupleContext(), node);
|
|
52486
|
+
typeResult.type = types_1.UnknownType.create();
|
|
52487
|
+
}
|
|
52488
|
+
}
|
|
52489
|
+
if (!(0, typeUtils_1.isEffectivelyInstantiable)(typeResult.type)) {
|
|
52490
|
+
const isEmptyVariadic = (0, types_1.isClassInstance)(typeResult.type) && types_1.ClassType.isTupleClass(typeResult.type) && ((_a = typeResult.type.tupleTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
52491
|
+
if (!isEmptyVariadic) {
|
|
52492
|
+
addExpectedClassDiagnostic(typeResult.type, node);
|
|
52493
|
+
typeResult.type = types_1.UnknownType.create();
|
|
52494
|
+
typeResult.typeErrors = true;
|
|
52495
|
+
}
|
|
52496
|
+
}
|
|
52497
|
+
}
|
|
51903
52498
|
function getTypeOfAwaitOperator(node, flags, inferenceContext) {
|
|
51904
52499
|
const effectiveExpectedType = inferenceContext ? createAwaitableReturnType(
|
|
51905
52500
|
node,
|
|
@@ -52185,55 +52780,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
52185
52780
|
}
|
|
52186
52781
|
return (0, typeUtils_1.convertToInstance)(annotationType);
|
|
52187
52782
|
}
|
|
52188
|
-
function getTypeOfDecorator(node, functionOrClassType) {
|
|
52189
|
-
let flags = AnalyzerNodeInfo.getFileInfo(node).isStubFile ? 4 : 0;
|
|
52190
|
-
if (node.expression.nodeType !== 9) {
|
|
52191
|
-
flags |= 2;
|
|
52192
|
-
}
|
|
52193
|
-
const decoratorTypeResult = getTypeOfExpression(node.expression, flags);
|
|
52194
|
-
if ((0, types_1.isFunction)(decoratorTypeResult.type) && decoratorTypeResult.type.details.builtInName === "type_check_only") {
|
|
52195
|
-
return functionOrClassType;
|
|
52196
|
-
}
|
|
52197
|
-
if ((0, types_1.isInstantiableClass)(decoratorTypeResult.type) && types_1.ClassType.isBuiltIn(decoratorTypeResult.type, "classmethod") && (0, typeUtils_1.isProperty)(functionOrClassType)) {
|
|
52198
|
-
return functionOrClassType;
|
|
52199
|
-
}
|
|
52200
|
-
const argList = [
|
|
52201
|
-
{
|
|
52202
|
-
argumentCategory: 0,
|
|
52203
|
-
typeResult: { type: functionOrClassType }
|
|
52204
|
-
}
|
|
52205
|
-
];
|
|
52206
|
-
const returnType = validateCallArguments(
|
|
52207
|
-
node.expression,
|
|
52208
|
-
argList,
|
|
52209
|
-
decoratorTypeResult,
|
|
52210
|
-
/* typeVarContext */
|
|
52211
|
-
void 0,
|
|
52212
|
-
/* skipUnknownArgCheck */
|
|
52213
|
-
true
|
|
52214
|
-
).returnType || types_1.UnknownType.create();
|
|
52215
|
-
if ((0, types_1.isFunction)(returnType) && !returnType.details.declaredReturnType) {
|
|
52216
|
-
if (!returnType.details.parameters.some((param, index) => {
|
|
52217
|
-
if (!param.name || param.hasDeclaredType) {
|
|
52218
|
-
return true;
|
|
52219
|
-
}
|
|
52220
|
-
if (param.category !== 0) {
|
|
52221
|
-
return false;
|
|
52222
|
-
}
|
|
52223
|
-
return index !== 0 || !param.isTypeInferred;
|
|
52224
|
-
})) {
|
|
52225
|
-
return functionOrClassType;
|
|
52226
|
-
}
|
|
52227
|
-
}
|
|
52228
|
-
if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
|
|
52229
|
-
if ((0, types_1.isFunction)(decoratorTypeResult.type)) {
|
|
52230
|
-
if (!decoratorTypeResult.type.details.parameters.find((param) => param.typeAnnotation !== void 0) && decoratorTypeResult.type.details.declaredReturnType === void 0) {
|
|
52231
|
-
return functionOrClassType;
|
|
52232
|
-
}
|
|
52233
|
-
}
|
|
52234
|
-
}
|
|
52235
|
-
return returnType;
|
|
52236
|
-
}
|
|
52237
52783
|
function canBeFalsy(type, recursionCount = 0) {
|
|
52238
52784
|
type = makeTopLevelTypeVarsConcrete(type);
|
|
52239
52785
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
|
@@ -52443,15 +52989,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
52443
52989
|
bindToType
|
|
52444
52990
|
);
|
|
52445
52991
|
}
|
|
52446
|
-
if (memberInfo && memberInfo.classType && memberInfo.symbol && (0, types_1.isClass)(memberInfo.classType) && types_1.ClassType.isProtocolClass(memberInfo.classType)) {
|
|
52447
|
-
const primaryDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(memberInfo.symbol);
|
|
52448
|
-
if (primaryDecl && primaryDecl.type === 1 && !memberInfo.isClassVar) {
|
|
52449
|
-
addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.protocolMemberNotClassVar().format({
|
|
52450
|
-
memberName,
|
|
52451
|
-
className: memberInfo.classType.details.name
|
|
52452
|
-
}), errorNode);
|
|
52453
|
-
}
|
|
52454
|
-
}
|
|
52455
52992
|
const isMemberPresentOnClass = (memberInfo === null || memberInfo === void 0 ? void 0 : memberInfo.classType) !== void 0;
|
|
52456
52993
|
if (!memberInfo) {
|
|
52457
52994
|
const metaclass = classType.details.effectiveMetaclass;
|
|
@@ -56212,7 +56749,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
56212
56749
|
}
|
|
56213
56750
|
return typeResult;
|
|
56214
56751
|
}
|
|
56215
|
-
function getTypeOfTuple(node,
|
|
56752
|
+
function getTypeOfTuple(node, flags, inferenceContext) {
|
|
56216
56753
|
if ((flags & 128) !== 0 && node.expressions.length === 0 && !inferenceContext) {
|
|
56217
56754
|
return { type: makeTupleObject([]), isEmptyTupleShorthand: true };
|
|
56218
56755
|
}
|
|
@@ -56359,7 +56896,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
56359
56896
|
}
|
|
56360
56897
|
return entryTypes;
|
|
56361
56898
|
}
|
|
56362
|
-
function getTypeOfCall(node,
|
|
56899
|
+
function getTypeOfCall(node, flags, inferenceContext) {
|
|
56363
56900
|
var _a;
|
|
56364
56901
|
let baseTypeResult;
|
|
56365
56902
|
if (node.leftExpression.nodeType === 30) {
|
|
@@ -57152,8 +57689,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
57152
57689
|
if (expandedSubtype.overloads[0].details.builtInName === "cast" && argList.length === 2) {
|
|
57153
57690
|
const castToType = getTypeOfArgumentExpectingType(argList[0]).type;
|
|
57154
57691
|
const castFromType = getTypeOfArgument(argList[1]).type;
|
|
57155
|
-
if (
|
|
57156
|
-
if ((0, types_1.isTypeSame)(
|
|
57692
|
+
if (types_1.TypeBase.isInstantiable(castToType) && !(0, types_1.isUnknown)(castToType)) {
|
|
57693
|
+
if ((0, types_1.isTypeSame)((0, typeUtils_1.convertToInstance)(castToType), castFromType, {
|
|
57157
57694
|
ignorePseudoGeneric: true
|
|
57158
57695
|
})) {
|
|
57159
57696
|
addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportUnnecessaryCast, diagnosticRules_1.DiagnosticRule.reportUnnecessaryCast, localize_1.Localizer.Diagnostic.unnecessaryCast().format({
|
|
@@ -57715,7 +58252,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57715
58252
|
let unpackedDictionaryArgType;
|
|
57716
58253
|
while (argIndex < argList.length) {
|
|
57717
58254
|
if (argList[argIndex].argumentCategory === 2) {
|
|
57718
|
-
const argType = getTypeOfArgument(argList[argIndex]).type;
|
|
58255
|
+
const argType = getTypeOfArgument(argList[argIndex], (0, typeUtils_1.makeInferenceContext)(paramDetails.unpackedKwargsTypedDictType)).type;
|
|
57719
58256
|
if ((0, types_1.isAnyOrUnknown)(argType)) {
|
|
57720
58257
|
unpackedDictionaryArgType = argType;
|
|
57721
58258
|
} else if ((0, types_1.isClassInstance)(argType) && types_1.ClassType.isTypedDictClass(argType)) {
|
|
@@ -58336,6 +58873,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
58336
58873
|
return returnType;
|
|
58337
58874
|
}
|
|
58338
58875
|
function validateFunctionArguments(errorNode, argList, typeResult, typeVarContext, skipUnknownArgCheck = false, inferenceContext) {
|
|
58876
|
+
var _a;
|
|
58877
|
+
const signatureTracker = (_a = inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.signatureTracker) !== null && _a !== void 0 ? _a : new typeUtils_1.UniqueSignatureTracker();
|
|
58878
|
+
typeResult.type = (0, typeUtils_1.ensureFunctionSignaturesAreUnique)(typeResult.type, signatureTracker, errorNode.start);
|
|
58339
58879
|
const matchResults = matchFunctionArgumentsToParameters(errorNode, argList, typeResult, 0);
|
|
58340
58880
|
if (matchResults.argumentErrors) {
|
|
58341
58881
|
argList.forEach((arg) => {
|
|
@@ -58349,7 +58889,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
58349
58889
|
overloadsUsedForCall: []
|
|
58350
58890
|
};
|
|
58351
58891
|
}
|
|
58352
|
-
return validateFunctionArgumentTypesWithContext(errorNode, matchResults, typeVarContext, skipUnknownArgCheck, inferenceContext);
|
|
58892
|
+
return validateFunctionArgumentTypesWithContext(errorNode, matchResults, typeVarContext, skipUnknownArgCheck, (0, typeUtils_1.makeInferenceContext)(inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.expectedType, inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.isTypeIncomplete, signatureTracker));
|
|
58353
58893
|
}
|
|
58354
58894
|
function validateFunctionArgumentsForParamSpec(errorNode, argList, paramSpec, destTypeVarContext, conditionFilter) {
|
|
58355
58895
|
const signatureContexts = destTypeVarContext.getSignatureContexts();
|
|
@@ -58527,7 +59067,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
58527
59067
|
if (argParam.argType) {
|
|
58528
59068
|
argType = argParam.argType;
|
|
58529
59069
|
} else {
|
|
58530
|
-
const flags = argParam.isinstanceParam ? 512 | 8 | 32 | 64 :
|
|
59070
|
+
const flags = argParam.isinstanceParam ? 512 | 8 | 32 | 64 : 2;
|
|
58531
59071
|
const exprTypeResult = getTypeOfExpression(argParam.argument.valueExpression, flags, (0, typeUtils_1.makeInferenceContext)(expectedType, !!(typeResult === null || typeResult === void 0 ? void 0 : typeResult.isIncomplete), signatureTracker));
|
|
58532
59072
|
argType = exprTypeResult.type;
|
|
58533
59073
|
argType = (0, typeUtils_1.ensureFunctionSignaturesAreUnique)(argType, signatureTracker, argParam.argument.valueExpression.start);
|
|
@@ -58563,16 +59103,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
58563
59103
|
} else {
|
|
58564
59104
|
if (argParam.argType) {
|
|
58565
59105
|
argType = argParam.argType;
|
|
58566
|
-
} else if (argParam.isinstanceParam && !argParam.argument.typeResult && argParam.argument.valueExpression) {
|
|
58567
|
-
const argTypeResult = getTypeOfExpression(
|
|
58568
|
-
argParam.argument.valueExpression,
|
|
58569
|
-
8 | 32 | 64
|
|
58570
|
-
/* DisallowTypeVarTuple */
|
|
58571
|
-
);
|
|
58572
|
-
argType = argTypeResult.type;
|
|
58573
|
-
if (argTypeResult.isIncomplete) {
|
|
58574
|
-
isTypeIncomplete = true;
|
|
58575
|
-
}
|
|
58576
59106
|
} else {
|
|
58577
59107
|
const argTypeResult = getTypeOfArgument(argParam.argument);
|
|
58578
59108
|
argType = argTypeResult.type;
|
|
@@ -59037,7 +59567,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59037
59567
|
let entryType = getTypeOfExpression(
|
|
59038
59568
|
expr,
|
|
59039
59569
|
128
|
|
59040
|
-
/*
|
|
59570
|
+
/* ExpectingInstantiableType */
|
|
59041
59571
|
).type;
|
|
59042
59572
|
if ((0, types_1.isTypeVar)(entryType)) {
|
|
59043
59573
|
if (entryType.scopeId) {
|
|
@@ -59067,7 +59597,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59067
59597
|
valueExpr,
|
|
59068
59598
|
/* typeParamNodes */
|
|
59069
59599
|
void 0,
|
|
59070
|
-
() => typeParameters
|
|
59600
|
+
() => typeParameters !== null && typeParameters !== void 0 ? typeParameters : []
|
|
59071
59601
|
);
|
|
59072
59602
|
}
|
|
59073
59603
|
function getBooleanValue(node) {
|
|
@@ -59981,15 +60511,20 @@ var require_typeEvaluator = __commonJS({
|
|
|
59981
60511
|
}
|
|
59982
60512
|
const expectedFunctionType = expectedFunctionTypes.length > 0 ? expectedFunctionTypes[0] : void 0;
|
|
59983
60513
|
let paramsArePositionOnly = true;
|
|
60514
|
+
const expectedParamDetails = expectedFunctionType ? (0, parameterUtils_1.getParameterListDetails)(expectedFunctionType) : void 0;
|
|
59984
60515
|
node.parameters.forEach((param, index) => {
|
|
59985
|
-
let paramType
|
|
59986
|
-
if (
|
|
59987
|
-
|
|
60516
|
+
let paramType;
|
|
60517
|
+
if (expectedParamDetails) {
|
|
60518
|
+
if (index < expectedParamDetails.params.length) {
|
|
60519
|
+
paramType = expectedParamDetails.params[index].type;
|
|
60520
|
+
} else if (param.defaultValue) {
|
|
60521
|
+
paramType = getTypeOfExpression(param.defaultValue, void 0, inferenceContext).type;
|
|
60522
|
+
}
|
|
59988
60523
|
}
|
|
59989
60524
|
if (param.name) {
|
|
59990
60525
|
writeTypeCache(
|
|
59991
60526
|
param.name,
|
|
59992
|
-
{ type: transformVariadicParamType(node, param.category, paramType) },
|
|
60527
|
+
{ type: transformVariadicParamType(node, param.category, paramType !== null && paramType !== void 0 ? paramType : types_1.UnknownType.create()) },
|
|
59993
60528
|
0
|
|
59994
60529
|
/* None */
|
|
59995
60530
|
);
|
|
@@ -60026,7 +60561,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
60026
60561
|
hasDefault: !!param.defaultValue,
|
|
60027
60562
|
defaultValueExpression: param.defaultValue,
|
|
60028
60563
|
hasDeclaredType: true,
|
|
60029
|
-
type: paramType
|
|
60564
|
+
type: paramType !== null && paramType !== void 0 ? paramType : types_1.UnknownType.create()
|
|
60030
60565
|
};
|
|
60031
60566
|
types_1.FunctionType.addParameter(functionType, functionParam);
|
|
60032
60567
|
});
|
|
@@ -60310,11 +60845,13 @@ var require_typeEvaluator = __commonJS({
|
|
|
60310
60845
|
hasDeclaredType: true
|
|
60311
60846
|
});
|
|
60312
60847
|
});
|
|
60313
|
-
|
|
60314
|
-
|
|
60315
|
-
|
|
60316
|
-
|
|
60317
|
-
|
|
60848
|
+
if (typeList.length > 0) {
|
|
60849
|
+
types_1.FunctionType.addParameter(functionType, {
|
|
60850
|
+
category: 0,
|
|
60851
|
+
isNameSynthesized: false,
|
|
60852
|
+
type: types_1.UnknownType.create()
|
|
60853
|
+
});
|
|
60854
|
+
}
|
|
60318
60855
|
} else if ((0, typeUtils_1.isEllipsisType)(typeArgs[0].type)) {
|
|
60319
60856
|
types_1.FunctionType.addDefaultParameters(functionType);
|
|
60320
60857
|
functionType.details.flags |= 32768;
|
|
@@ -60544,7 +61081,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
60544
61081
|
}
|
|
60545
61082
|
const enclosingFunction = ParseTreeUtils.getEnclosingFunction(errorNode);
|
|
60546
61083
|
if (enclosingFunction) {
|
|
60547
|
-
const functionFlags = getFunctionFlagsFromDecorators(
|
|
61084
|
+
const functionFlags = (0, decorators_1.getFunctionFlagsFromDecorators)(
|
|
61085
|
+
evaluatorInterface,
|
|
60548
61086
|
enclosingFunction,
|
|
60549
61087
|
/* isInClass */
|
|
60550
61088
|
true
|
|
@@ -61653,7 +62191,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
61653
62191
|
let foundUnknown = false;
|
|
61654
62192
|
for (let i = node.decorators.length - 1; i >= 0; i--) {
|
|
61655
62193
|
const decorator = node.decorators[i];
|
|
61656
|
-
const newDecoratedType = applyClassDecorator(decoratedType, classType, decorator);
|
|
62194
|
+
const newDecoratedType = (0, decorators_1.applyClassDecorator)(evaluatorInterface, decoratedType, classType, decorator);
|
|
61657
62195
|
const unknownOrAny = (0, typeUtils_1.containsAnyOrUnknown)(
|
|
61658
62196
|
newDecoratedType,
|
|
61659
62197
|
/* recurse */
|
|
@@ -61919,91 +62457,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
61919
62457
|
addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeVarsNotInGenericOrProtocol() + diag.getString(), errorNode);
|
|
61920
62458
|
}
|
|
61921
62459
|
}
|
|
61922
|
-
function applyClassDecorator(inputClassType, originalClassType, decoratorNode) {
|
|
61923
|
-
const fileInfo = AnalyzerNodeInfo.getFileInfo(decoratorNode);
|
|
61924
|
-
let flags = fileInfo.isStubFile ? 4 : 0;
|
|
61925
|
-
if (decoratorNode.expression.nodeType !== 9) {
|
|
61926
|
-
flags |= 2;
|
|
61927
|
-
}
|
|
61928
|
-
const decoratorType = getTypeOfExpression(decoratorNode.expression, flags).type;
|
|
61929
|
-
if (decoratorNode.expression.nodeType === 9) {
|
|
61930
|
-
const decoratorCallType = getTypeOfExpression(
|
|
61931
|
-
decoratorNode.expression.leftExpression,
|
|
61932
|
-
flags | 2
|
|
61933
|
-
/* DoNotSpecialize */
|
|
61934
|
-
).type;
|
|
61935
|
-
if ((0, types_1.isFunction)(decoratorCallType)) {
|
|
61936
|
-
if (decoratorCallType.details.name === "__dataclass_transform__" || decoratorCallType.details.builtInName === "dataclass_transform") {
|
|
61937
|
-
originalClassType.details.classDataClassTransform = (0, dataClasses_1.validateDataClassTransformDecorator)(evaluatorInterface, decoratorNode.expression);
|
|
61938
|
-
} else if (decoratorCallType.details.builtInName === "deprecated") {
|
|
61939
|
-
originalClassType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
61940
|
-
return inputClassType;
|
|
61941
|
-
}
|
|
61942
|
-
}
|
|
61943
|
-
if ((0, types_1.isOverloadedFunction)(decoratorCallType)) {
|
|
61944
|
-
if (decoratorCallType.overloads.length > 0 && decoratorCallType.overloads[0].details.builtInName === "deprecated") {
|
|
61945
|
-
originalClassType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
61946
|
-
return inputClassType;
|
|
61947
|
-
}
|
|
61948
|
-
}
|
|
61949
|
-
}
|
|
61950
|
-
if ((0, types_1.isOverloadedFunction)(decoratorType)) {
|
|
61951
|
-
const dataclassBehaviors = (0, dataClasses_1.getDataclassDecoratorBehaviors)(decoratorType);
|
|
61952
|
-
if (dataclassBehaviors) {
|
|
61953
|
-
(0, dataClasses_1.applyDataClassDecorator)(
|
|
61954
|
-
evaluatorInterface,
|
|
61955
|
-
decoratorNode,
|
|
61956
|
-
originalClassType,
|
|
61957
|
-
dataclassBehaviors,
|
|
61958
|
-
/* callNode */
|
|
61959
|
-
void 0
|
|
61960
|
-
);
|
|
61961
|
-
return inputClassType;
|
|
61962
|
-
}
|
|
61963
|
-
if (decoratorType.overloads.length > 0 && decoratorType.overloads[0].details.builtInName === "deprecated") {
|
|
61964
|
-
originalClassType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
61965
|
-
return inputClassType;
|
|
61966
|
-
}
|
|
61967
|
-
} else if ((0, types_1.isFunction)(decoratorType)) {
|
|
61968
|
-
if (decoratorType.details.builtInName === "final") {
|
|
61969
|
-
originalClassType.details.flags |= 4096;
|
|
61970
|
-
return inputClassType;
|
|
61971
|
-
}
|
|
61972
|
-
if (decoratorType.details.builtInName === "deprecated") {
|
|
61973
|
-
originalClassType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
61974
|
-
return inputClassType;
|
|
61975
|
-
}
|
|
61976
|
-
if (decoratorType.details.builtInName === "runtime_checkable") {
|
|
61977
|
-
originalClassType.details.flags |= 32768;
|
|
61978
|
-
return inputClassType;
|
|
61979
|
-
}
|
|
61980
|
-
let dataclassBehaviors;
|
|
61981
|
-
let callNode;
|
|
61982
|
-
if (decoratorNode.expression.nodeType === 9) {
|
|
61983
|
-
callNode = decoratorNode.expression;
|
|
61984
|
-
const decoratorCallType = getTypeOfExpression(
|
|
61985
|
-
callNode.leftExpression,
|
|
61986
|
-
flags | 2
|
|
61987
|
-
/* DoNotSpecialize */
|
|
61988
|
-
).type;
|
|
61989
|
-
dataclassBehaviors = (0, dataClasses_1.getDataclassDecoratorBehaviors)(decoratorCallType);
|
|
61990
|
-
} else {
|
|
61991
|
-
const decoratorType2 = getTypeOfExpression(decoratorNode.expression, flags).type;
|
|
61992
|
-
dataclassBehaviors = (0, dataClasses_1.getDataclassDecoratorBehaviors)(decoratorType2);
|
|
61993
|
-
}
|
|
61994
|
-
if (dataclassBehaviors) {
|
|
61995
|
-
(0, dataClasses_1.applyDataClassDecorator)(evaluatorInterface, decoratorNode, originalClassType, dataclassBehaviors, callNode);
|
|
61996
|
-
return inputClassType;
|
|
61997
|
-
}
|
|
61998
|
-
}
|
|
61999
|
-
return getTypeOfDecorator(decoratorNode, inputClassType);
|
|
62000
|
-
}
|
|
62001
|
-
function getCustomDeprecationMessage(decorator) {
|
|
62002
|
-
if (decorator.expression.nodeType === 9 && decorator.expression.arguments.length > 0 && decorator.expression.arguments[0].argumentCategory === 0 && decorator.expression.arguments[0].valueExpression.nodeType === 48 && decorator.expression.arguments[0].valueExpression.strings.length === 1) {
|
|
62003
|
-
return decorator.expression.arguments[0].valueExpression.strings[0].value;
|
|
62004
|
-
}
|
|
62005
|
-
return "";
|
|
62006
|
-
}
|
|
62007
62460
|
function runClassTypeHooks(type) {
|
|
62008
62461
|
classTypeHooks.forEach((hook) => {
|
|
62009
62462
|
if (types_1.ClassType.isSameGenericClass(hook.dependency, type)) {
|
|
@@ -62157,7 +62610,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62157
62610
|
}
|
|
62158
62611
|
containingClassType = classInfo.classType;
|
|
62159
62612
|
}
|
|
62160
|
-
let functionFlags = getFunctionFlagsFromDecorators(node, !!containingClassNode);
|
|
62613
|
+
let functionFlags = (0, decorators_1.getFunctionFlagsFromDecorators)(evaluatorInterface, node, !!containingClassNode);
|
|
62161
62614
|
if (functionDecl === null || functionDecl === void 0 ? void 0 : functionDecl.isGenerator) {
|
|
62162
62615
|
functionFlags |= 16;
|
|
62163
62616
|
}
|
|
@@ -62432,7 +62885,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62432
62885
|
let foundUnknown = false;
|
|
62433
62886
|
for (let i = node.decorators.length - 1; i >= 0; i--) {
|
|
62434
62887
|
const decorator = node.decorators[i];
|
|
62435
|
-
const newDecoratedType = applyFunctionDecorator(decoratedType, functionType, decorator, node);
|
|
62888
|
+
const newDecoratedType = (0, decorators_1.applyFunctionDecorator)(evaluatorInterface, decoratedType, functionType, decorator, node);
|
|
62436
62889
|
const unknownOrAny = (0, typeUtils_1.containsAnyOrUnknown)(
|
|
62437
62890
|
newDecoratedType,
|
|
62438
62891
|
/* recurse */
|
|
@@ -62453,7 +62906,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62453
62906
|
markParamAccessed(param);
|
|
62454
62907
|
});
|
|
62455
62908
|
}
|
|
62456
|
-
decoratedType = addOverloadsToFunctionType(node, decoratedType);
|
|
62909
|
+
decoratedType = (0, decorators_1.addOverloadsToFunctionType)(evaluatorInterface, node, decoratedType);
|
|
62457
62910
|
}
|
|
62458
62911
|
writeTypeCache(
|
|
62459
62912
|
node.name,
|
|
@@ -62525,6 +62978,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
62525
62978
|
const baseClassParamAnnotation = (_a = baseClassParam.typeAnnotation) !== null && _a !== void 0 ? _a : baseClassParam.typeAnnotationComment;
|
|
62526
62979
|
if (baseClassParamAnnotation) {
|
|
62527
62980
|
let inferredParamType = getTypeOfParameterAnnotation(baseClassParamAnnotation, functionNode.parameters[paramIndex].category);
|
|
62981
|
+
if ((0, typeUtils_1.requiresSpecialization)(inferredParamType) && (0, types_1.isClass)(baseClassMemberInfo.classType)) {
|
|
62982
|
+
const typeVarContext = (0, typeUtils_1.buildTypeVarContextFromSpecializedClass)(baseClassMemberInfo.classType);
|
|
62983
|
+
inferredParamType = (0, typeUtils_1.applySolvedTypeVars)(inferredParamType, typeVarContext);
|
|
62984
|
+
}
|
|
62528
62985
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(functionNode);
|
|
62529
62986
|
if (fileInfo.isInPyTypedPackage && !fileInfo.isStubFile) {
|
|
62530
62987
|
inferredParamType = types_1.TypeBase.cloneForAmbiguousType(inferredParamType);
|
|
@@ -62613,227 +63070,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
62613
63070
|
}
|
|
62614
63071
|
}
|
|
62615
63072
|
}
|
|
62616
|
-
function getFunctionFlagsFromDecorators(node, isInClass) {
|
|
62617
|
-
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
|
62618
|
-
let flags = 0;
|
|
62619
|
-
if (isInClass) {
|
|
62620
|
-
if (node.name.value === "__new__") {
|
|
62621
|
-
flags |= 1;
|
|
62622
|
-
}
|
|
62623
|
-
const implicitClassMethods = ["__init_subclass__", "__class_getitem__"];
|
|
62624
|
-
if (implicitClassMethods.some((name) => node.name.value === name)) {
|
|
62625
|
-
flags |= 2;
|
|
62626
|
-
}
|
|
62627
|
-
}
|
|
62628
|
-
for (const decoratorNode of node.decorators) {
|
|
62629
|
-
let evaluatorFlags = fileInfo.isStubFile ? 4 : 0;
|
|
62630
|
-
if (decoratorNode.expression.nodeType !== 9) {
|
|
62631
|
-
evaluatorFlags |= 2;
|
|
62632
|
-
}
|
|
62633
|
-
const decoratorTypeResult = getTypeOfExpression(decoratorNode.expression, evaluatorFlags);
|
|
62634
|
-
const decoratorType = decoratorTypeResult.type;
|
|
62635
|
-
if ((0, types_1.isFunction)(decoratorType)) {
|
|
62636
|
-
if (decoratorType.details.builtInName === "abstractmethod") {
|
|
62637
|
-
if (isInClass) {
|
|
62638
|
-
flags |= 8;
|
|
62639
|
-
}
|
|
62640
|
-
} else if (decoratorType.details.builtInName === "final") {
|
|
62641
|
-
flags |= 8192;
|
|
62642
|
-
} else if (decoratorType.details.builtInName === "override") {
|
|
62643
|
-
flags |= 262144;
|
|
62644
|
-
}
|
|
62645
|
-
} else if ((0, types_1.isInstantiableClass)(decoratorType)) {
|
|
62646
|
-
if (types_1.ClassType.isBuiltIn(decoratorType, "staticmethod")) {
|
|
62647
|
-
if (isInClass) {
|
|
62648
|
-
flags |= 4;
|
|
62649
|
-
}
|
|
62650
|
-
} else if (types_1.ClassType.isBuiltIn(decoratorType, "classmethod")) {
|
|
62651
|
-
if (isInClass) {
|
|
62652
|
-
flags |= 2;
|
|
62653
|
-
}
|
|
62654
|
-
}
|
|
62655
|
-
}
|
|
62656
|
-
}
|
|
62657
|
-
return flags;
|
|
62658
|
-
}
|
|
62659
|
-
function applyFunctionDecorator(inputFunctionType, undecoratedType, decoratorNode, functionNode) {
|
|
62660
|
-
const fileInfo = AnalyzerNodeInfo.getFileInfo(decoratorNode);
|
|
62661
|
-
let evaluatorFlags = fileInfo.isStubFile ? 4 : 0;
|
|
62662
|
-
if (decoratorNode.expression.nodeType !== 9) {
|
|
62663
|
-
evaluatorFlags |= 2;
|
|
62664
|
-
}
|
|
62665
|
-
const decoratorTypeResult = getTypeOfExpression(decoratorNode.expression, evaluatorFlags);
|
|
62666
|
-
const decoratorType = decoratorTypeResult.type;
|
|
62667
|
-
if ((0, types_1.isInstantiableClass)(decoratorType) && types_1.ClassType.isSpecialBuiltIn(decoratorType, "overload") || (0, types_1.isFunction)(decoratorType) && decoratorType.details.builtInName === "overload") {
|
|
62668
|
-
if ((0, types_1.isFunction)(inputFunctionType)) {
|
|
62669
|
-
inputFunctionType.details.flags |= 256;
|
|
62670
|
-
undecoratedType.details.flags |= 256;
|
|
62671
|
-
return inputFunctionType;
|
|
62672
|
-
}
|
|
62673
|
-
}
|
|
62674
|
-
if (decoratorNode.expression.nodeType === 9) {
|
|
62675
|
-
const decoratorCallType = getTypeOfExpression(
|
|
62676
|
-
decoratorNode.expression.leftExpression,
|
|
62677
|
-
evaluatorFlags | 2
|
|
62678
|
-
/* DoNotSpecialize */
|
|
62679
|
-
).type;
|
|
62680
|
-
if ((0, types_1.isFunction)(decoratorCallType)) {
|
|
62681
|
-
if (decoratorCallType.details.name === "__dataclass_transform__" || decoratorCallType.details.builtInName === "dataclass_transform") {
|
|
62682
|
-
undecoratedType.details.decoratorDataClassBehaviors = (0, dataClasses_1.validateDataClassTransformDecorator)(evaluatorInterface, decoratorNode.expression);
|
|
62683
|
-
return inputFunctionType;
|
|
62684
|
-
}
|
|
62685
|
-
if (decoratorCallType.details.builtInName === "deprecated") {
|
|
62686
|
-
undecoratedType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
62687
|
-
return inputFunctionType;
|
|
62688
|
-
}
|
|
62689
|
-
}
|
|
62690
|
-
if ((0, types_1.isOverloadedFunction)(decoratorCallType)) {
|
|
62691
|
-
if (decoratorCallType.overloads.length > 0 && decoratorCallType.overloads[0].details.builtInName === "deprecated") {
|
|
62692
|
-
undecoratedType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
62693
|
-
return inputFunctionType;
|
|
62694
|
-
}
|
|
62695
|
-
}
|
|
62696
|
-
}
|
|
62697
|
-
let returnType = getTypeOfDecorator(decoratorNode, inputFunctionType);
|
|
62698
|
-
if ((0, types_1.isFunction)(decoratorType)) {
|
|
62699
|
-
if (decoratorType.details.builtInName === "abstractmethod") {
|
|
62700
|
-
return inputFunctionType;
|
|
62701
|
-
}
|
|
62702
|
-
if (decoratorType.details.builtInName === "deprecated") {
|
|
62703
|
-
undecoratedType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
62704
|
-
return inputFunctionType;
|
|
62705
|
-
}
|
|
62706
|
-
if (decoratorNode.expression.nodeType === 35) {
|
|
62707
|
-
const baseType = getTypeOfExpression(
|
|
62708
|
-
decoratorNode.expression.leftExpression,
|
|
62709
|
-
evaluatorFlags | 2
|
|
62710
|
-
/* DoNotSpecialize */
|
|
62711
|
-
).type;
|
|
62712
|
-
if ((0, typeUtils_1.isProperty)(baseType)) {
|
|
62713
|
-
const memberName = decoratorNode.expression.memberName.value;
|
|
62714
|
-
if (memberName === "setter") {
|
|
62715
|
-
if ((0, types_1.isFunction)(inputFunctionType)) {
|
|
62716
|
-
(0, properties_1.validatePropertyMethod)(evaluatorInterface, inputFunctionType, decoratorNode);
|
|
62717
|
-
return (0, properties_1.clonePropertyWithSetter)(evaluatorInterface, baseType, inputFunctionType, functionNode);
|
|
62718
|
-
} else {
|
|
62719
|
-
return inputFunctionType;
|
|
62720
|
-
}
|
|
62721
|
-
} else if (memberName === "deleter") {
|
|
62722
|
-
if ((0, types_1.isFunction)(inputFunctionType)) {
|
|
62723
|
-
(0, properties_1.validatePropertyMethod)(evaluatorInterface, inputFunctionType, decoratorNode);
|
|
62724
|
-
return (0, properties_1.clonePropertyWithDeleter)(evaluatorInterface, baseType, inputFunctionType, functionNode);
|
|
62725
|
-
} else {
|
|
62726
|
-
return inputFunctionType;
|
|
62727
|
-
}
|
|
62728
|
-
}
|
|
62729
|
-
}
|
|
62730
|
-
}
|
|
62731
|
-
} else if ((0, types_1.isOverloadedFunction)(decoratorType)) {
|
|
62732
|
-
if (decoratorType.overloads.length > 0 && decoratorType.overloads[0].details.builtInName === "deprecated") {
|
|
62733
|
-
undecoratedType.details.deprecatedMessage = getCustomDeprecationMessage(decoratorNode);
|
|
62734
|
-
return inputFunctionType;
|
|
62735
|
-
}
|
|
62736
|
-
} else if ((0, types_1.isInstantiableClass)(decoratorType)) {
|
|
62737
|
-
if (types_1.ClassType.isBuiltIn(decoratorType)) {
|
|
62738
|
-
switch (decoratorType.details.name) {
|
|
62739
|
-
case "classmethod":
|
|
62740
|
-
case "staticmethod": {
|
|
62741
|
-
const requiredFlag = decoratorType.details.name === "classmethod" ? 2 : 4;
|
|
62742
|
-
if ((0, types_1.isFunction)(inputFunctionType) && (inputFunctionType.details.flags & requiredFlag) === 0) {
|
|
62743
|
-
const newFunction = types_1.FunctionType.clone(inputFunctionType);
|
|
62744
|
-
newFunction.details.flags &= ~(1 | 4 | 2);
|
|
62745
|
-
newFunction.details.flags |= requiredFlag;
|
|
62746
|
-
return newFunction;
|
|
62747
|
-
}
|
|
62748
|
-
return inputFunctionType;
|
|
62749
|
-
}
|
|
62750
|
-
}
|
|
62751
|
-
}
|
|
62752
|
-
if (types_1.ClassType.isPropertyClass(decoratorType)) {
|
|
62753
|
-
if ((0, types_1.isFunction)(inputFunctionType)) {
|
|
62754
|
-
(0, properties_1.validatePropertyMethod)(evaluatorInterface, inputFunctionType, decoratorNode);
|
|
62755
|
-
return (0, properties_1.createProperty)(evaluatorInterface, decoratorNode, decoratorType, inputFunctionType);
|
|
62756
|
-
} else if ((0, types_1.isClassInstance)(inputFunctionType)) {
|
|
62757
|
-
const boundMethod = getBoundMethod(inputFunctionType, "__call__");
|
|
62758
|
-
if (boundMethod && (0, types_1.isFunction)(boundMethod)) {
|
|
62759
|
-
return (0, properties_1.createProperty)(evaluatorInterface, decoratorNode, decoratorType, boundMethod);
|
|
62760
|
-
}
|
|
62761
|
-
return types_1.UnknownType.create();
|
|
62762
|
-
}
|
|
62763
|
-
}
|
|
62764
|
-
}
|
|
62765
|
-
if ((0, types_1.isFunction)(inputFunctionType) && (0, types_1.isFunction)(returnType)) {
|
|
62766
|
-
returnType = types_1.FunctionType.clone(returnType);
|
|
62767
|
-
if (types_1.FunctionType.isOverloaded(inputFunctionType)) {
|
|
62768
|
-
returnType.details.flags |= 256;
|
|
62769
|
-
}
|
|
62770
|
-
if (!returnType.details.docString) {
|
|
62771
|
-
returnType.details.docString = inputFunctionType.details.docString;
|
|
62772
|
-
}
|
|
62773
|
-
}
|
|
62774
|
-
return returnType;
|
|
62775
|
-
}
|
|
62776
|
-
function addOverloadsToFunctionType(node, type) {
|
|
62777
|
-
let functionDecl;
|
|
62778
|
-
const decl = AnalyzerNodeInfo.getDeclaration(node);
|
|
62779
|
-
if (decl) {
|
|
62780
|
-
functionDecl = decl;
|
|
62781
|
-
}
|
|
62782
|
-
const symbolWithScope = lookUpSymbolRecursive(
|
|
62783
|
-
node,
|
|
62784
|
-
node.name.value,
|
|
62785
|
-
/* honorCodeFlow */
|
|
62786
|
-
false
|
|
62787
|
-
);
|
|
62788
|
-
if (symbolWithScope) {
|
|
62789
|
-
const decls = symbolWithScope.symbol.getDeclarations();
|
|
62790
|
-
const declIndex = decls.findIndex((decl2) => decl2 === functionDecl);
|
|
62791
|
-
if (declIndex > 0) {
|
|
62792
|
-
for (let i = 0; i < declIndex; i++) {
|
|
62793
|
-
const decl2 = decls[i];
|
|
62794
|
-
if (decl2.type === 5) {
|
|
62795
|
-
getTypeOfFunction(decl2.node);
|
|
62796
|
-
}
|
|
62797
|
-
}
|
|
62798
|
-
let overloadedTypes = [];
|
|
62799
|
-
const prevDecl = decls[declIndex - 1];
|
|
62800
|
-
if (prevDecl.type === 5) {
|
|
62801
|
-
const prevDeclDeclTypeInfo = getTypeOfFunction(prevDecl.node);
|
|
62802
|
-
if (prevDeclDeclTypeInfo) {
|
|
62803
|
-
if ((0, types_1.isFunction)(prevDeclDeclTypeInfo.decoratedType)) {
|
|
62804
|
-
if (types_1.FunctionType.isOverloaded(prevDeclDeclTypeInfo.decoratedType)) {
|
|
62805
|
-
overloadedTypes.push(prevDeclDeclTypeInfo.decoratedType);
|
|
62806
|
-
}
|
|
62807
|
-
} else if ((0, types_1.isOverloadedFunction)(prevDeclDeclTypeInfo.decoratedType)) {
|
|
62808
|
-
(0, collectionUtils_1.appendArray)(overloadedTypes, prevDeclDeclTypeInfo.decoratedType.overloads);
|
|
62809
|
-
}
|
|
62810
|
-
}
|
|
62811
|
-
}
|
|
62812
|
-
overloadedTypes.push(type);
|
|
62813
|
-
if (overloadedTypes.length === 1) {
|
|
62814
|
-
return overloadedTypes[0];
|
|
62815
|
-
}
|
|
62816
|
-
const implementation = overloadedTypes.find((signature) => !types_1.FunctionType.isOverloaded(signature));
|
|
62817
|
-
if (implementation === null || implementation === void 0 ? void 0 : implementation.details.docString) {
|
|
62818
|
-
overloadedTypes = overloadedTypes.map((overload) => {
|
|
62819
|
-
if (types_1.FunctionType.isOverloaded(overload) && !overload.details.docString) {
|
|
62820
|
-
return types_1.FunctionType.cloneWithDocString(overload, implementation.details.docString);
|
|
62821
|
-
}
|
|
62822
|
-
return overload;
|
|
62823
|
-
});
|
|
62824
|
-
}
|
|
62825
|
-
const newOverload = types_1.OverloadedFunctionType.create(overloadedTypes);
|
|
62826
|
-
const prevOverload = overloadedTypes[overloadedTypes.length - 2];
|
|
62827
|
-
const isPrevOverloadAbstract = types_1.FunctionType.isAbstractMethod(prevOverload);
|
|
62828
|
-
const isCurrentOverloadAbstract = types_1.FunctionType.isAbstractMethod(type);
|
|
62829
|
-
if (isPrevOverloadAbstract !== isCurrentOverloadAbstract) {
|
|
62830
|
-
addDiagnostic(AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadAbstractMismatch().format({ name: node.name.value }), node.name);
|
|
62831
|
-
}
|
|
62832
|
-
return newOverload;
|
|
62833
|
-
}
|
|
62834
|
-
}
|
|
62835
|
-
return type;
|
|
62836
|
-
}
|
|
62837
63073
|
function createAsyncFunction(node, functionType) {
|
|
62838
63074
|
const awaitableFunctionType = types_1.FunctionType.clone(functionType);
|
|
62839
63075
|
if (functionType.details.declaredReturnType) {
|
|
@@ -63765,7 +64001,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
63765
64001
|
return;
|
|
63766
64002
|
}
|
|
63767
64003
|
}
|
|
63768
|
-
const functionFlags = getFunctionFlagsFromDecorators(
|
|
64004
|
+
const functionFlags = (0, decorators_1.getFunctionFlagsFromDecorators)(
|
|
64005
|
+
evaluatorInterface,
|
|
63769
64006
|
functionNode,
|
|
63770
64007
|
/* isInClass */
|
|
63771
64008
|
true
|
|
@@ -64232,14 +64469,19 @@ var require_typeEvaluator = __commonJS({
|
|
|
64232
64469
|
const specializedClass = types_1.ClassType.cloneForSpecialization(classType, typeArgTypes, typeArgs !== void 0);
|
|
64233
64470
|
return { type: specializedClass };
|
|
64234
64471
|
}
|
|
64235
|
-
function getTypeOfArgument(arg) {
|
|
64472
|
+
function getTypeOfArgument(arg, inferenceContext) {
|
|
64236
64473
|
if (arg.typeResult) {
|
|
64237
64474
|
return { type: arg.typeResult.type, isIncomplete: arg.typeResult.isIncomplete };
|
|
64238
64475
|
}
|
|
64239
64476
|
if (!arg.valueExpression) {
|
|
64240
64477
|
return { type: types_1.UnknownType.create() };
|
|
64241
64478
|
}
|
|
64242
|
-
return getTypeOfExpression(
|
|
64479
|
+
return getTypeOfExpression(
|
|
64480
|
+
arg.valueExpression,
|
|
64481
|
+
/* flags */
|
|
64482
|
+
void 0,
|
|
64483
|
+
inferenceContext
|
|
64484
|
+
);
|
|
64243
64485
|
}
|
|
64244
64486
|
function getTypeOfArgumentExpectingType(arg) {
|
|
64245
64487
|
if (arg.typeResult) {
|
|
@@ -65590,43 +65832,47 @@ var require_typeEvaluator = __commonJS({
|
|
|
65590
65832
|
let isAssignable = true;
|
|
65591
65833
|
destType.details.fields.forEach((symbol, name) => {
|
|
65592
65834
|
var _a;
|
|
65593
|
-
if (isAssignable
|
|
65594
|
-
|
|
65595
|
-
|
|
65596
|
-
|
|
65597
|
-
|
|
65598
|
-
|
|
65599
|
-
|
|
65600
|
-
|
|
65601
|
-
|
|
65602
|
-
|
|
65603
|
-
|
|
65604
|
-
|
|
65605
|
-
|
|
65606
|
-
|
|
65607
|
-
|
|
65608
|
-
|
|
65609
|
-
|
|
65610
|
-
|
|
65611
|
-
|
|
65612
|
-
|
|
65613
|
-
|
|
65614
|
-
|
|
65615
|
-
|
|
65616
|
-
|
|
65617
|
-
|
|
65618
|
-
|
|
65619
|
-
|
|
65620
|
-
|
|
65621
|
-
|
|
65622
|
-
|
|
65623
|
-
|
|
65624
|
-
|
|
65625
|
-
|
|
65626
|
-
|
|
65627
|
-
|
|
65628
|
-
|
|
65629
|
-
|
|
65835
|
+
if (!isAssignable || !symbol.isClassMember() || symbol.isIgnoredForProtocolMatch()) {
|
|
65836
|
+
return;
|
|
65837
|
+
}
|
|
65838
|
+
if (name === "__new__" || name === "__init__") {
|
|
65839
|
+
return;
|
|
65840
|
+
}
|
|
65841
|
+
const memberInfo = (0, typeUtils_1.lookUpClassMember)(srcType, name);
|
|
65842
|
+
(0, debug_1.assert)(memberInfo !== void 0);
|
|
65843
|
+
let destMemberType = (_a = getDeclaredTypeOfSymbol(symbol)) === null || _a === void 0 ? void 0 : _a.type;
|
|
65844
|
+
if (destMemberType) {
|
|
65845
|
+
const srcMemberType = getTypeOfMember(memberInfo);
|
|
65846
|
+
destMemberType = (0, typeUtils_1.partiallySpecializeType)(destMemberType, destType);
|
|
65847
|
+
if ((0, types_1.isClassInstance)(destMemberType) && types_1.ClassType.isPropertyClass(destMemberType) && (0, types_1.isClassInstance)(srcMemberType) && types_1.ClassType.isPropertyClass(srcMemberType)) {
|
|
65848
|
+
if (!(0, properties_1.assignProperty)(
|
|
65849
|
+
evaluatorInterface,
|
|
65850
|
+
types_1.ClassType.cloneAsInstantiable(destMemberType),
|
|
65851
|
+
types_1.ClassType.cloneAsInstantiable(srcMemberType),
|
|
65852
|
+
destType,
|
|
65853
|
+
srcType,
|
|
65854
|
+
diag,
|
|
65855
|
+
typeVarContext,
|
|
65856
|
+
/* selfTypeVarContext */
|
|
65857
|
+
void 0,
|
|
65858
|
+
recursionCount
|
|
65859
|
+
)) {
|
|
65860
|
+
isAssignable = false;
|
|
65861
|
+
}
|
|
65862
|
+
} else {
|
|
65863
|
+
const primaryDecl = symbol.getDeclarations()[0];
|
|
65864
|
+
const flags = (primaryDecl === null || primaryDecl === void 0 ? void 0 : primaryDecl.type) === 1 && !isFinalVariableDeclaration(primaryDecl) ? 1 : 0;
|
|
65865
|
+
if (!assignType(
|
|
65866
|
+
destMemberType,
|
|
65867
|
+
srcMemberType,
|
|
65868
|
+
diag,
|
|
65869
|
+
typeVarContext,
|
|
65870
|
+
/* srcTypeVarContext */
|
|
65871
|
+
void 0,
|
|
65872
|
+
flags,
|
|
65873
|
+
recursionCount
|
|
65874
|
+
)) {
|
|
65875
|
+
isAssignable = false;
|
|
65630
65876
|
}
|
|
65631
65877
|
}
|
|
65632
65878
|
}
|
|
@@ -65708,7 +65954,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
65708
65954
|
}
|
|
65709
65955
|
}
|
|
65710
65956
|
}
|
|
65711
|
-
function
|
|
65957
|
+
function assignTupleTypeArguments(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
|
|
65712
65958
|
var _a, _b;
|
|
65713
65959
|
const destTypeArgs = [...(_a = destType.tupleTypeArguments) !== null && _a !== void 0 ? _a : []];
|
|
65714
65960
|
const srcTypeArgs = [...(_b = srcType.tupleTypeArguments) !== null && _b !== void 0 ? _b : []];
|
|
@@ -65746,25 +65992,23 @@ var require_typeEvaluator = __commonJS({
|
|
|
65746
65992
|
function assignClassWithTypeArgs(destType, srcType, inheritanceChain, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
|
|
65747
65993
|
let curSrcType = srcType;
|
|
65748
65994
|
let prevSrcType;
|
|
65749
|
-
let curDestTypeVarContext = destTypeVarContext;
|
|
65750
|
-
let effectiveFlags = flags;
|
|
65751
65995
|
inferTypeParameterVarianceForClass(destType);
|
|
65752
|
-
|
|
65753
|
-
|
|
65754
|
-
|
|
65755
|
-
|
|
65996
|
+
if ((flags & 1) !== 0) {
|
|
65997
|
+
const srcIsLiteral = srcType.literalValue !== void 0;
|
|
65998
|
+
const destIsLiteral = destType.literalValue !== void 0;
|
|
65999
|
+
if (srcIsLiteral !== destIsLiteral) {
|
|
66000
|
+
return false;
|
|
66001
|
+
}
|
|
65756
66002
|
} else {
|
|
65757
|
-
|
|
66003
|
+
if (types_1.ClassType.isBuiltIn(destType, "object")) {
|
|
66004
|
+
return true;
|
|
66005
|
+
}
|
|
65758
66006
|
}
|
|
65759
66007
|
for (let ancestorIndex = inheritanceChain.length - 1; ancestorIndex >= 0; ancestorIndex--) {
|
|
65760
66008
|
const ancestorType = inheritanceChain[ancestorIndex];
|
|
65761
|
-
const curSrcTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(curSrcType));
|
|
65762
66009
|
if ((0, types_1.isUnknown)(ancestorType)) {
|
|
65763
66010
|
return true;
|
|
65764
66011
|
}
|
|
65765
|
-
if (types_1.ClassType.isBuiltIn(ancestorType, "object")) {
|
|
65766
|
-
return true;
|
|
65767
|
-
}
|
|
65768
66012
|
if (ancestorIndex < inheritanceChain.length - 1) {
|
|
65769
66013
|
let effectiveCurSrcType = curSrcType;
|
|
65770
66014
|
if (types_1.ClassType.isBuiltIn(curSrcType, "NamedTuple") && types_1.ClassType.isBuiltIn(ancestorType, "tuple") && prevSrcType) {
|
|
@@ -65772,9 +66016,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
65772
66016
|
}
|
|
65773
66017
|
curSrcType = (0, typeUtils_1.specializeForBaseClass)(effectiveCurSrcType, ancestorType);
|
|
65774
66018
|
}
|
|
65775
|
-
if (ancestorIndex === 0 && destType.tupleTypeArguments && curSrcType.tupleTypeArguments) {
|
|
65776
|
-
return assignTupleTypeArgs(destType, curSrcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount);
|
|
65777
|
-
}
|
|
65778
66019
|
const ancestorTypeParams = types_1.ClassType.getTypeParameters(ancestorType);
|
|
65779
66020
|
if (ancestorTypeParams.length === 0) {
|
|
65780
66021
|
continue;
|
|
@@ -65782,11 +66023,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
65782
66023
|
if (!ancestorType.typeArguments) {
|
|
65783
66024
|
return true;
|
|
65784
66025
|
}
|
|
65785
|
-
if (!verifyTypeArgumentsAssignable(ancestorType, curSrcType, diag, curDestTypeVarContext, curSrcTypeVarContext, effectiveFlags, recursionCount)) {
|
|
65786
|
-
return false;
|
|
65787
|
-
}
|
|
65788
|
-
curDestTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(ancestorType));
|
|
65789
|
-
effectiveFlags &= ~8;
|
|
65790
66026
|
prevSrcType = curSrcType;
|
|
65791
66027
|
}
|
|
65792
66028
|
if ((flags & 1) !== 0) {
|
|
@@ -65796,11 +66032,13 @@ var require_typeEvaluator = __commonJS({
|
|
|
65796
66032
|
return false;
|
|
65797
66033
|
}
|
|
65798
66034
|
}
|
|
66035
|
+
if (destType.tupleTypeArguments && curSrcType.tupleTypeArguments) {
|
|
66036
|
+
return assignTupleTypeArguments(destType, curSrcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount);
|
|
66037
|
+
}
|
|
65799
66038
|
if (destType.typeArguments) {
|
|
65800
|
-
|
|
65801
|
-
|
|
65802
|
-
|
|
65803
|
-
} else if (destTypeVarContext && destType.details.typeParameters.length > 0 && curSrcType.typeArguments && !destTypeVarContext.isLocked()) {
|
|
66039
|
+
return assignTypeArguments(destType, curSrcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount);
|
|
66040
|
+
}
|
|
66041
|
+
if (destTypeVarContext && curSrcType.typeArguments && !destTypeVarContext.isLocked()) {
|
|
65804
66042
|
const srcTypeArgs = curSrcType.typeArguments;
|
|
65805
66043
|
for (let i = 0; i < destType.details.typeParameters.length; i++) {
|
|
65806
66044
|
const typeArgType = i < srcTypeArgs.length ? srcTypeArgs[i] : types_1.UnknownType.create();
|
|
@@ -65835,7 +66073,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
65835
66073
|
}
|
|
65836
66074
|
return void 0;
|
|
65837
66075
|
}
|
|
65838
|
-
function
|
|
66076
|
+
function assignTypeArguments(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
|
|
65839
66077
|
var _a, _b, _c;
|
|
65840
66078
|
(0, debug_1.assert)(types_1.ClassType.isSameGenericClass(destType, srcType));
|
|
65841
66079
|
inferTypeParameterVarianceForClass(destType);
|
|
@@ -65887,7 +66125,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
65887
66125
|
isCompatible = false;
|
|
65888
66126
|
}
|
|
65889
66127
|
} else {
|
|
65890
|
-
if (!assignType(destTypeArg, srcTypeArg, assignmentDiag, destTypeVarContext, srcTypeVarContext, flags | 1, recursionCount)) {
|
|
66128
|
+
if (!assignType(destTypeArg, srcTypeArg, assignmentDiag, destTypeVarContext, srcTypeVarContext, flags | 1 | 128, recursionCount)) {
|
|
65891
66129
|
if (!types_1.ClassType.isPseudoGenericClass(destType)) {
|
|
65892
66130
|
if (diag) {
|
|
65893
66131
|
const childDiag = diag.createAddendum();
|
|
@@ -66357,7 +66595,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66357
66595
|
return true;
|
|
66358
66596
|
}
|
|
66359
66597
|
if ((0, types_1.isFunction)(concreteSrcType)) {
|
|
66360
|
-
if (assignFunction(destType, concreteSrcType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext !== null && destTypeVarContext !== void 0 ? destTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType)), srcTypeVarContext !== null && srcTypeVarContext !== void 0 ? srcTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.
|
|
66598
|
+
if (assignFunction(destType, concreteSrcType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext !== null && destTypeVarContext !== void 0 ? destTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType)), srcTypeVarContext !== null && srcTypeVarContext !== void 0 ? srcTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeIds)(concreteSrcType)), flags, recursionCount)) {
|
|
66361
66599
|
return true;
|
|
66362
66600
|
}
|
|
66363
66601
|
}
|
|
@@ -67813,7 +68051,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67813
68051
|
let isAbstract;
|
|
67814
68052
|
const decl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(symbol);
|
|
67815
68053
|
if (decl && decl.type === 5) {
|
|
67816
|
-
const functionFlags = getFunctionFlagsFromDecorators(decl.node, true);
|
|
68054
|
+
const functionFlags = (0, decorators_1.getFunctionFlagsFromDecorators)(evaluatorInterface, decl.node, true);
|
|
67817
68055
|
isAbstract = !!(functionFlags & 8);
|
|
67818
68056
|
} else {
|
|
67819
68057
|
isAbstract = false;
|
|
@@ -67939,7 +68177,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67939
68177
|
typeVarContext,
|
|
67940
68178
|
/* srcTypeVarContext */
|
|
67941
68179
|
void 0,
|
|
67942
|
-
|
|
68180
|
+
2048,
|
|
67943
68181
|
recursionCount
|
|
67944
68182
|
)) {
|
|
67945
68183
|
if (memberTypeFirstParam.name && !memberTypeFirstParam.isNameSynthesized && memberTypeFirstParam.hasDeclaredType) {
|
|
@@ -68031,6 +68269,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
68031
68269
|
if (options === null || options === void 0 ? void 0 : options.printUnknownWithAny) {
|
|
68032
68270
|
flags |= 1;
|
|
68033
68271
|
}
|
|
68272
|
+
if (options === null || options === void 0 ? void 0 : options.printTypeVarVariance) {
|
|
68273
|
+
flags |= 2048;
|
|
68274
|
+
}
|
|
68034
68275
|
if (options === null || options === void 0 ? void 0 : options.omitTypeArgumentsIfUnknown) {
|
|
68035
68276
|
flags |= 2;
|
|
68036
68277
|
}
|
|
@@ -68169,7 +68410,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
68169
68410
|
getObjectType,
|
|
68170
68411
|
getBuiltInObject,
|
|
68171
68412
|
getTypingType,
|
|
68172
|
-
|
|
68413
|
+
assignTypeArguments,
|
|
68173
68414
|
reportMissingTypeArguments,
|
|
68174
68415
|
inferReturnTypeIfNecessary,
|
|
68175
68416
|
inferTypeParameterVarianceForClass,
|
|
@@ -97700,7 +97941,6 @@ var PythonFormattingEditProvider = class {
|
|
|
97700
97941
|
const provider = this.pythonSettings.formatting.provider;
|
|
97701
97942
|
const formatter = this.formatters.get(provider);
|
|
97702
97943
|
if (!formatter) {
|
|
97703
|
-
import_coc9.window.showWarningMessage(`No formatter is set. You need to set "python.formatting.provider" in your coc-settings.json`);
|
|
97704
97944
|
this.outputChannel.appendLine(`${"#".repeat(10)} Error: python.formatting.provider is ${provider}, which is not supported`);
|
|
97705
97945
|
return [];
|
|
97706
97946
|
}
|