coc-pyright 1.1.303 → 1.1.304
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 +530 -240
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -8892,7 +8892,11 @@ var require_parseTreeUtils = __commonJS({
|
|
|
8892
8892
|
return printExpression(node.leftExpression, flags) + "." + node.memberName.value;
|
|
8893
8893
|
}
|
|
8894
8894
|
case 9: {
|
|
8895
|
-
|
|
8895
|
+
let lhs = printExpression(node.leftExpression, flags);
|
|
8896
|
+
if (node.leftExpression.nodeType !== 35 && node.leftExpression.nodeType !== 38 && node.leftExpression.nodeType !== 24 && node.leftExpression.nodeType !== 9) {
|
|
8897
|
+
lhs = `(${lhs})`;
|
|
8898
|
+
}
|
|
8899
|
+
return lhs + "(" + node.arguments.map((arg) => printArgument(arg, flags)).join(", ") + ")";
|
|
8896
8900
|
}
|
|
8897
8901
|
case 24: {
|
|
8898
8902
|
return printExpression(node.baseExpression, flags) + "[" + node.items.map((item) => printArgument(item, flags)).join(", ") + (node.trailingComma ? "," : "") + "]";
|
|
@@ -22006,7 +22010,7 @@ var require_configOptions = __commonJS({
|
|
|
22006
22010
|
function getOffDiagnosticRuleSet() {
|
|
22007
22011
|
const diagSettings = {
|
|
22008
22012
|
printUnknownAsAny: true,
|
|
22009
|
-
|
|
22013
|
+
omitTypeArgsIfUnknown: true,
|
|
22010
22014
|
omitUnannotatedParamType: true,
|
|
22011
22015
|
omitConditionalConstraint: true,
|
|
22012
22016
|
pep604Printing: true,
|
|
@@ -22087,7 +22091,7 @@ var require_configOptions = __commonJS({
|
|
|
22087
22091
|
function getBasicDiagnosticRuleSet() {
|
|
22088
22092
|
const diagSettings = {
|
|
22089
22093
|
printUnknownAsAny: false,
|
|
22090
|
-
|
|
22094
|
+
omitTypeArgsIfUnknown: false,
|
|
22091
22095
|
omitUnannotatedParamType: true,
|
|
22092
22096
|
omitConditionalConstraint: false,
|
|
22093
22097
|
pep604Printing: true,
|
|
@@ -22168,7 +22172,7 @@ var require_configOptions = __commonJS({
|
|
|
22168
22172
|
function getStrictDiagnosticRuleSet() {
|
|
22169
22173
|
const diagSettings = {
|
|
22170
22174
|
printUnknownAsAny: false,
|
|
22171
|
-
|
|
22175
|
+
omitTypeArgsIfUnknown: false,
|
|
22172
22176
|
omitUnannotatedParamType: false,
|
|
22173
22177
|
omitConditionalConstraint: false,
|
|
22174
22178
|
pep604Printing: true,
|
|
@@ -23451,7 +23455,7 @@ var require_declarationUtils = __commonJS({
|
|
|
23451
23455
|
if (!symbol) {
|
|
23452
23456
|
if (curDeclaration.submoduleFallback) {
|
|
23453
23457
|
if (curDeclaration.symbolName) {
|
|
23454
|
-
if (curDeclaration.submoduleFallback.type === 8 && curDeclaration.submoduleFallback.path) {
|
|
23458
|
+
if (curDeclaration.path && curDeclaration.submoduleFallback.type === 8 && curDeclaration.submoduleFallback.path) {
|
|
23455
23459
|
const lookupResult2 = importLookup(curDeclaration.submoduleFallback.path);
|
|
23456
23460
|
if (!lookupResult2) {
|
|
23457
23461
|
return void 0;
|
|
@@ -24376,11 +24380,11 @@ var require_types = __commonJS({
|
|
|
24376
24380
|
return isIncomplete ? _incompleteInstance : _instance;
|
|
24377
24381
|
}
|
|
24378
24382
|
UnknownType2.create = create;
|
|
24379
|
-
function createPossibleType(possibleType) {
|
|
24383
|
+
function createPossibleType(possibleType, isIncomplete) {
|
|
24380
24384
|
const unknownWithPossibleType = {
|
|
24381
24385
|
category: 1,
|
|
24382
24386
|
flags: 1 | 2,
|
|
24383
|
-
isIncomplete
|
|
24387
|
+
isIncomplete,
|
|
24384
24388
|
possibleType
|
|
24385
24389
|
};
|
|
24386
24390
|
return unknownWithPossibleType;
|
|
@@ -25009,6 +25013,13 @@ var require_types = __commonJS({
|
|
|
25009
25013
|
return newFunction;
|
|
25010
25014
|
}
|
|
25011
25015
|
FunctionType2.cloneWithNewFlags = cloneWithNewFlags;
|
|
25016
|
+
function cloneWithNewTypeVarScopeId(type, newScopeId) {
|
|
25017
|
+
const newFunction = TypeBase.cloneType(type);
|
|
25018
|
+
newFunction.details = { ...type.details };
|
|
25019
|
+
newFunction.details.typeVarScopeId = newScopeId;
|
|
25020
|
+
return newFunction;
|
|
25021
|
+
}
|
|
25022
|
+
FunctionType2.cloneWithNewTypeVarScopeId = cloneWithNewTypeVarScopeId;
|
|
25012
25023
|
function cloneWithDocString(type, docString) {
|
|
25013
25024
|
const newFunction = TypeBase.cloneType(type);
|
|
25014
25025
|
newFunction.details = { ...type.details };
|
|
@@ -29017,10 +29028,10 @@ var require_typeUtils = __commonJS({
|
|
|
29017
29028
|
const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
|
|
29018
29029
|
if (typeVar.scopeId && this._typeVarContext.hasSolveForScope(typeVar.scopeId)) {
|
|
29019
29030
|
let replacement = signatureContext.getTypeVarType(typeVar, !!this._options.useNarrowBoundOnly);
|
|
29020
|
-
if (!replacement &&
|
|
29031
|
+
if (!replacement && this._options.useNarrowBoundOnly) {
|
|
29021
29032
|
const wideType = signatureContext.getTypeVarType(typeVar);
|
|
29022
29033
|
if (wideType) {
|
|
29023
|
-
if (containsLiteralType(
|
|
29034
|
+
if ((0, types_1.isTypeVar)(wideType) || containsLiteralType(
|
|
29024
29035
|
wideType,
|
|
29025
29036
|
/* includeTypeArgs */
|
|
29026
29037
|
true
|
|
@@ -29899,7 +29910,7 @@ var require_sourceMapper = __commonJS({
|
|
|
29899
29910
|
const filePath = type.details.filePath;
|
|
29900
29911
|
const sourceFiles = this._getSourceFiles(
|
|
29901
29912
|
filePath,
|
|
29902
|
-
/*stubToShadow*/
|
|
29913
|
+
/* stubToShadow */
|
|
29903
29914
|
void 0,
|
|
29904
29915
|
originated
|
|
29905
29916
|
);
|
|
@@ -32857,7 +32868,7 @@ var require_typePrinter = __commonJS({
|
|
|
32857
32868
|
(function(PrintTypeFlags2) {
|
|
32858
32869
|
PrintTypeFlags2[PrintTypeFlags2["None"] = 0] = "None";
|
|
32859
32870
|
PrintTypeFlags2[PrintTypeFlags2["PrintUnknownWithAny"] = 1] = "PrintUnknownWithAny";
|
|
32860
|
-
PrintTypeFlags2[PrintTypeFlags2["
|
|
32871
|
+
PrintTypeFlags2[PrintTypeFlags2["OmitTypeArgumentsIfUnknown"] = 2] = "OmitTypeArgumentsIfUnknown";
|
|
32861
32872
|
PrintTypeFlags2[PrintTypeFlags2["OmitUnannotatedParamType"] = 4] = "OmitUnannotatedParamType";
|
|
32862
32873
|
PrintTypeFlags2[PrintTypeFlags2["PEP604"] = 8] = "PEP604";
|
|
32863
32874
|
PrintTypeFlags2[PrintTypeFlags2["ParenthesizeUnion"] = 16] = "ParenthesizeUnion";
|
|
@@ -32896,7 +32907,7 @@ var require_typePrinter = __commonJS({
|
|
|
32896
32907
|
if (typeParams) {
|
|
32897
32908
|
let argumentStrings;
|
|
32898
32909
|
if (type.typeAliasInfo.typeArguments) {
|
|
32899
|
-
if ((printTypeFlags & 2) === 0 || type.typeAliasInfo.typeArguments.some((typeArg) => !(0, types_1.
|
|
32910
|
+
if ((printTypeFlags & 2) === 0 || type.typeAliasInfo.typeArguments.some((typeArg) => !(0, types_1.isUnknown)(typeArg))) {
|
|
32900
32911
|
argumentStrings = [];
|
|
32901
32912
|
type.typeAliasInfo.typeArguments.forEach((typeArg, index) => {
|
|
32902
32913
|
const typeParam = index < typeParams.length ? typeParams[index] : typeParams[typeParams.length - 1];
|
|
@@ -32910,7 +32921,7 @@ var require_typePrinter = __commonJS({
|
|
|
32910
32921
|
});
|
|
32911
32922
|
}
|
|
32912
32923
|
} else {
|
|
32913
|
-
if ((printTypeFlags & 2) === 0 || typeParams.some((typeParam) => !(0, types_1.
|
|
32924
|
+
if ((printTypeFlags & 2) === 0 || typeParams.some((typeParam) => !(0, types_1.isUnknown)(typeParam))) {
|
|
32914
32925
|
argumentStrings = [];
|
|
32915
32926
|
typeParams.forEach((typeParam) => {
|
|
32916
32927
|
argumentStrings.push(printType(typeParam, printTypeFlags, returnTypeCallback, recursionTypes, recursionCount));
|
|
@@ -33189,7 +33200,10 @@ var require_typePrinter = __commonJS({
|
|
|
33189
33200
|
}
|
|
33190
33201
|
});
|
|
33191
33202
|
if (type.details.paramSpec) {
|
|
33192
|
-
|
|
33203
|
+
if (paramTypes.length > 0) {
|
|
33204
|
+
return `Callable[Concatenate[${paramTypes.join(", ")}, ${type.details.paramSpec.details.name}], ${returnTypeString}]`;
|
|
33205
|
+
}
|
|
33206
|
+
return `Callable[${type.details.paramSpec.details.name}, ${returnTypeString}]`;
|
|
33193
33207
|
}
|
|
33194
33208
|
return `Callable[[${paramTypes.join(", ")}], ${returnTypeString}]`;
|
|
33195
33209
|
} else {
|
|
@@ -33271,21 +33285,21 @@ var require_typePrinter = __commonJS({
|
|
|
33271
33285
|
if (typeArgs) {
|
|
33272
33286
|
if (typeArgs.length > 0) {
|
|
33273
33287
|
const typeArgStrings = [];
|
|
33274
|
-
let
|
|
33288
|
+
let isAllUnknown = true;
|
|
33275
33289
|
typeArgs.forEach((typeArg, index) => {
|
|
33276
33290
|
const typeParam = index < typeParams.length ? typeParams[index] : void 0;
|
|
33277
33291
|
if (typeParam && typeParam.details.isVariadic && (0, types_1.isClassInstance)(typeArg.type) && types_1.ClassType.isBuiltIn(typeArg.type, "tuple") && typeArg.type.tupleTypeArguments) {
|
|
33278
33292
|
if (typeArg.type.tupleTypeArguments.length === 0) {
|
|
33279
|
-
if (!(0, types_1.
|
|
33280
|
-
|
|
33293
|
+
if (!(0, types_1.isUnknown)(typeArg.type)) {
|
|
33294
|
+
isAllUnknown = false;
|
|
33281
33295
|
}
|
|
33282
33296
|
if (index === 0) {
|
|
33283
33297
|
typeArgStrings.push(_printUnpack("tuple[()]", printTypeFlags));
|
|
33284
33298
|
}
|
|
33285
33299
|
} else {
|
|
33286
33300
|
typeArgStrings.push(...typeArg.type.tupleTypeArguments.map((typeArg2) => {
|
|
33287
|
-
if (!(0, types_1.
|
|
33288
|
-
|
|
33301
|
+
if (!(0, types_1.isUnknown)(typeArg2.type)) {
|
|
33302
|
+
isAllUnknown = false;
|
|
33289
33303
|
}
|
|
33290
33304
|
const typeArgText = printType(typeArg2.type, printTypeFlags, returnTypeCallback, recursionTypes, recursionCount);
|
|
33291
33305
|
if (typeArg2.isUnbounded) {
|
|
@@ -33295,8 +33309,8 @@ var require_typePrinter = __commonJS({
|
|
|
33295
33309
|
}));
|
|
33296
33310
|
}
|
|
33297
33311
|
} else {
|
|
33298
|
-
if (!(0, types_1.
|
|
33299
|
-
|
|
33312
|
+
if (!(0, types_1.isUnknown)(typeArg.type)) {
|
|
33313
|
+
isAllUnknown = false;
|
|
33300
33314
|
}
|
|
33301
33315
|
const typeArgTypeText = printType(typeArg.type, printTypeFlags, returnTypeCallback, recursionTypes, recursionCount);
|
|
33302
33316
|
if (typeArg.isUnbounded) {
|
|
@@ -33313,7 +33327,7 @@ var require_typePrinter = __commonJS({
|
|
|
33313
33327
|
if (type.isUnpacked) {
|
|
33314
33328
|
objName = _printUnpack(objName, printTypeFlags);
|
|
33315
33329
|
}
|
|
33316
|
-
if ((printTypeFlags & 2) === 0 || !
|
|
33330
|
+
if ((printTypeFlags & 2) === 0 || !isAllUnknown) {
|
|
33317
33331
|
objName += "[" + typeArgStrings.join(", ") + "]";
|
|
33318
33332
|
}
|
|
33319
33333
|
} else {
|
|
@@ -33329,7 +33343,7 @@ var require_typePrinter = __commonJS({
|
|
|
33329
33343
|
objName = _printUnpack(objName, printTypeFlags);
|
|
33330
33344
|
}
|
|
33331
33345
|
if (typeParams.length > 0) {
|
|
33332
|
-
if ((printTypeFlags & 2) === 0 || typeParams.some((typeParam) => !(0, types_1.
|
|
33346
|
+
if ((printTypeFlags & 2) === 0 || typeParams.some((typeParam) => !(0, types_1.isUnknown)(typeParam))) {
|
|
33333
33347
|
objName += "[" + typeParams.map((typeParam) => {
|
|
33334
33348
|
return printType(typeParam, printTypeFlags, returnTypeCallback, recursionTypes, recursionCount);
|
|
33335
33349
|
}).join(", ") + "]";
|
|
@@ -34285,7 +34299,7 @@ var require_autoImporter = __commonJS({
|
|
|
34285
34299
|
ImportFormat2["Absolute"] = "absolute";
|
|
34286
34300
|
ImportFormat2["Relative"] = "relative";
|
|
34287
34301
|
})(ImportFormat = exports.ImportFormat || (exports.ImportFormat = {}));
|
|
34288
|
-
function buildModuleSymbolsMap(files,
|
|
34302
|
+
function buildModuleSymbolsMap(files, includeSymbolsFromIndices, token) {
|
|
34289
34303
|
const moduleSymbolMap = /* @__PURE__ */ new Map();
|
|
34290
34304
|
(0, cancellationUtils_1.throwIfCancellationRequested)(token);
|
|
34291
34305
|
files.forEach((file) => {
|
|
@@ -34329,7 +34343,7 @@ var require_autoImporter = __commonJS({
|
|
|
34329
34343
|
return;
|
|
34330
34344
|
}
|
|
34331
34345
|
const indexResults = file.sourceFile.getCachedIndexResults();
|
|
34332
|
-
if (indexResults &&
|
|
34346
|
+
if (indexResults && includeSymbolsFromIndices && !indexResults.privateOrProtected) {
|
|
34333
34347
|
moduleSymbolMap.set(filePath, createModuleSymbolTableFromIndexResult(
|
|
34334
34348
|
indexResults,
|
|
34335
34349
|
/* library */
|
|
@@ -35086,7 +35100,20 @@ var require_completionProviderUtils = __commonJS({
|
|
|
35086
35100
|
}
|
|
35087
35101
|
}
|
|
35088
35102
|
}
|
|
35089
|
-
|
|
35103
|
+
if (type.category === 6 || type.category === 5) {
|
|
35104
|
+
return (0, tooltipUtils_1.getToolTipForType)(
|
|
35105
|
+
type,
|
|
35106
|
+
/* label */
|
|
35107
|
+
"",
|
|
35108
|
+
name,
|
|
35109
|
+
evaluator,
|
|
35110
|
+
/* isProperty */
|
|
35111
|
+
false,
|
|
35112
|
+
functionSignatureDisplay
|
|
35113
|
+
);
|
|
35114
|
+
} else {
|
|
35115
|
+
return name + ": " + evaluator.printType(type, { expandTypeAlias });
|
|
35116
|
+
}
|
|
35090
35117
|
}
|
|
35091
35118
|
case 5: {
|
|
35092
35119
|
const functionType = (detail === null || detail === void 0 ? void 0 : detail.boundObjectOrClass) && ((0, types_1.isFunction)(type) || (0, types_1.isOverloadedFunction)(type)) ? evaluator.bindFunctionToClassOrObject(detail.boundObjectOrClass, type) : type;
|
|
@@ -35103,11 +35130,11 @@ var require_completionProviderUtils = __commonJS({
|
|
|
35103
35130
|
}
|
|
35104
35131
|
return (0, tooltipUtils_1.getToolTipForType)(
|
|
35105
35132
|
functionType,
|
|
35106
|
-
/*label*/
|
|
35133
|
+
/* label */
|
|
35107
35134
|
"",
|
|
35108
35135
|
name,
|
|
35109
35136
|
evaluator,
|
|
35110
|
-
/*isProperty*/
|
|
35137
|
+
/* isProperty */
|
|
35111
35138
|
false,
|
|
35112
35139
|
functionSignatureDisplay
|
|
35113
35140
|
);
|
|
@@ -35258,7 +35285,7 @@ var require_documentSymbolCollector = __commonJS({
|
|
|
35258
35285
|
useCase,
|
|
35259
35286
|
evaluator,
|
|
35260
35287
|
token,
|
|
35261
|
-
/*skipUnreachableCode*/
|
|
35288
|
+
/* skipUnreachableCode */
|
|
35262
35289
|
false
|
|
35263
35290
|
);
|
|
35264
35291
|
let builtinsScope = AnalyzerNodeInfo.getFileInfo(node).builtinsScope;
|
|
@@ -36312,69 +36339,73 @@ var require_completionProvider = __commonJS({
|
|
|
36312
36339
|
if (!classResults) {
|
|
36313
36340
|
return void 0;
|
|
36314
36341
|
}
|
|
36315
|
-
const symbolTable = /* @__PURE__ */ new Map();
|
|
36316
|
-
for (let i = 1; i < classResults.classType.details.mro.length; i++) {
|
|
36317
|
-
const mroClass = classResults.classType.details.mro[i];
|
|
36318
|
-
if ((0, types_1.isInstantiableClass)(mroClass)) {
|
|
36319
|
-
(0, typeUtils_1.getMembersForClass)(
|
|
36320
|
-
mroClass,
|
|
36321
|
-
symbolTable,
|
|
36322
|
-
/* includeInstanceVars */
|
|
36323
|
-
false
|
|
36324
|
-
);
|
|
36325
|
-
}
|
|
36326
|
-
}
|
|
36327
36342
|
const staticmethod = (_a = decorators === null || decorators === void 0 ? void 0 : decorators.some((d) => this._checkDecorator(d, "staticmethod"))) !== null && _a !== void 0 ? _a : false;
|
|
36328
36343
|
const classmethod = (_b = decorators === null || decorators === void 0 ? void 0 : decorators.some((d) => this._checkDecorator(d, "classmethod"))) !== null && _b !== void 0 ? _b : false;
|
|
36329
|
-
const
|
|
36330
|
-
|
|
36331
|
-
|
|
36332
|
-
|
|
36333
|
-
|
|
36334
|
-
|
|
36335
|
-
|
|
36336
|
-
|
|
36337
|
-
|
|
36338
|
-
|
|
36339
|
-
|
|
36340
|
-
|
|
36341
|
-
|
|
36342
|
-
|
|
36343
|
-
|
|
36344
|
-
|
|
36345
|
-
|
|
36346
|
-
|
|
36347
|
-
|
|
36348
|
-
|
|
36349
|
-
|
|
36350
|
-
|
|
36351
|
-
|
|
36352
|
-
|
|
36353
|
-
|
|
36354
|
-
|
|
36355
|
-
|
|
36356
|
-
|
|
36357
|
-
|
|
36358
|
-
let text;
|
|
36359
|
-
if ((0, sourceMapper_1.isStubFile)(this._filePath)) {
|
|
36360
|
-
text = `${methodSignature}: ...`;
|
|
36361
|
-
} else {
|
|
36362
|
-
const methodBody = this._printOverriddenMethodBody(classResults.classType, isDeclaredStaticMethod, isProperty, decl);
|
|
36363
|
-
text = `${methodSignature}:
|
|
36364
|
-
${methodBody}`;
|
|
36365
|
-
}
|
|
36366
|
-
const textEdit = this._createReplaceEdits(priorWord, partialName, text);
|
|
36367
|
-
this._addSymbol(name, symbol, partialName.value, completionMap, {
|
|
36368
|
-
// method signature already contains ()
|
|
36369
|
-
funcParensDisabled: true,
|
|
36370
|
-
edits: {
|
|
36371
|
-
format: this._options.snippet ? vscode_languageserver_1.InsertTextFormat.Snippet : void 0,
|
|
36372
|
-
textEdit
|
|
36373
|
-
}
|
|
36374
|
-
});
|
|
36344
|
+
const appendMember = (map, member, name) => {
|
|
36345
|
+
if (!(0, types_1.isInstantiableClass)(member.classType) || member.classType.details === classResults.classType.details || !StringUtils.isPatternInSymbol(partialName.value, name)) {
|
|
36346
|
+
return;
|
|
36347
|
+
}
|
|
36348
|
+
const symbol = member.symbol;
|
|
36349
|
+
const decl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(symbol);
|
|
36350
|
+
if (!decl || decl.type !== 5) {
|
|
36351
|
+
return;
|
|
36352
|
+
}
|
|
36353
|
+
const declaredType = this._evaluator.getTypeOfMember(member);
|
|
36354
|
+
if (!declaredType) {
|
|
36355
|
+
return;
|
|
36356
|
+
}
|
|
36357
|
+
const isDeclaredStaticMethod = (0, types_1.isFunction)(declaredType) && types_1.FunctionType.isStaticMethod(declaredType);
|
|
36358
|
+
const isDeclaredClassMethod = (0, types_1.isFunction)(declaredType) && types_1.FunctionType.isClassMethod(declaredType) && name !== "__init_subclass__";
|
|
36359
|
+
if (staticmethod !== isDeclaredStaticMethod || classmethod !== isDeclaredClassMethod) {
|
|
36360
|
+
return;
|
|
36361
|
+
}
|
|
36362
|
+
let isProperty = (0, types_1.isClassInstance)(declaredType) && types_1.ClassType.isPropertyClass(declaredType);
|
|
36363
|
+
if (SymbolNameUtils.isDunderName(name)) {
|
|
36364
|
+
isProperty = false;
|
|
36365
|
+
}
|
|
36366
|
+
let funcType = void 0;
|
|
36367
|
+
if ((0, types_1.isFunction)(declaredType)) {
|
|
36368
|
+
funcType = declaredType;
|
|
36369
|
+
} else if (isProperty) {
|
|
36370
|
+
const getter = (0, typeUtils_1.lookUpClassMember)(declaredType, "fget");
|
|
36371
|
+
if (!getter) {
|
|
36372
|
+
return;
|
|
36375
36373
|
}
|
|
36374
|
+
const member2 = this._evaluator.getTypeOfMember(getter);
|
|
36375
|
+
if (!(0, types_1.isFunction)(member2)) {
|
|
36376
|
+
return;
|
|
36377
|
+
}
|
|
36378
|
+
funcType = member2;
|
|
36376
36379
|
}
|
|
36377
|
-
|
|
36380
|
+
if (!funcType || !funcType.details.declaration) {
|
|
36381
|
+
return;
|
|
36382
|
+
}
|
|
36383
|
+
const methodSignature = this._printMethodSignature(classResults.classType, funcType);
|
|
36384
|
+
let text;
|
|
36385
|
+
if ((0, sourceMapper_1.isStubFile)(this._filePath)) {
|
|
36386
|
+
text = `${methodSignature}: ...`;
|
|
36387
|
+
} else {
|
|
36388
|
+
const methodBody = this._printOverriddenMethodBody(classResults.classType, isDeclaredStaticMethod, isProperty, decl);
|
|
36389
|
+
text = `${methodSignature}:
|
|
36390
|
+
${methodBody}`;
|
|
36391
|
+
}
|
|
36392
|
+
const textEdit = this._createReplaceEdits(priorWord, partialName, text);
|
|
36393
|
+
this._addSymbol(name, symbol, partialName.value, map, {
|
|
36394
|
+
// method signature already contains ()
|
|
36395
|
+
funcParensDisabled: true,
|
|
36396
|
+
edits: {
|
|
36397
|
+
format: this._options.snippet ? vscode_languageserver_1.InsertTextFormat.Snippet : void 0,
|
|
36398
|
+
textEdit
|
|
36399
|
+
}
|
|
36400
|
+
});
|
|
36401
|
+
};
|
|
36402
|
+
const completionMap = new CompletionMap();
|
|
36403
|
+
const classMemberMap = (0, typeUtils_1.getClassFieldsRecursive)(classResults.classType);
|
|
36404
|
+
classMemberMap.forEach((member, name) => appendMember(completionMap, member, name));
|
|
36405
|
+
if (classResults.classType.details.effectiveMetaclass && !(0, types_1.isUnknown)(classResults.classType.details.effectiveMetaclass)) {
|
|
36406
|
+
const metaClassMemberMap = (0, typeUtils_1.getClassFieldsRecursive)(classResults.classType.details.effectiveMetaclass);
|
|
36407
|
+
metaClassMemberMap.forEach((member, name) => appendMember(completionMap, member, name));
|
|
36408
|
+
}
|
|
36378
36409
|
return { completionMap };
|
|
36379
36410
|
}
|
|
36380
36411
|
_createReplaceEdits(priorWord, node, text) {
|
|
@@ -36385,16 +36416,25 @@ ${methodBody}`;
|
|
|
36385
36416
|
};
|
|
36386
36417
|
return vscode_languageserver_1.TextEdit.replace(range, text);
|
|
36387
36418
|
}
|
|
36388
|
-
_printMethodSignature(classType,
|
|
36389
|
-
const
|
|
36419
|
+
_printMethodSignature(classType, funcType) {
|
|
36420
|
+
const decl = funcType.details.declaration;
|
|
36390
36421
|
let ellipsisForDefault;
|
|
36391
36422
|
if ((0, sourceMapper_1.isStubFile)(this._filePath)) {
|
|
36392
36423
|
ellipsisForDefault = true;
|
|
36393
36424
|
} else if (classType.details.moduleName === decl.moduleName) {
|
|
36394
36425
|
ellipsisForDefault = false;
|
|
36395
36426
|
}
|
|
36396
|
-
const
|
|
36397
|
-
const
|
|
36427
|
+
const printOptionsUsingSyntax = (0, sourceMapper_1.isStubFile)(this._filePath) ? 1 | 2 : 2;
|
|
36428
|
+
const printOptionsUsingType = {
|
|
36429
|
+
enforcePythonSyntax: true,
|
|
36430
|
+
expandTypeAlias: false,
|
|
36431
|
+
omitTypeArgumentsIfUnknown: true,
|
|
36432
|
+
printUnknownWithAny: true
|
|
36433
|
+
};
|
|
36434
|
+
const getTypeToPrint = (mainType, fallbackType) => {
|
|
36435
|
+
return mainType && (!(0, types_1.isUnknown)(mainType) || (fallbackType === null || fallbackType === void 0 ? void 0 : fallbackType.category) === 10) ? mainType : fallbackType;
|
|
36436
|
+
};
|
|
36437
|
+
const paramList = funcType.details.parameters.map((param, index) => {
|
|
36398
36438
|
let paramString = "";
|
|
36399
36439
|
if (param.category === 1) {
|
|
36400
36440
|
paramString += "*";
|
|
@@ -36402,43 +36442,74 @@ ${methodBody}`;
|
|
|
36402
36442
|
paramString += "**";
|
|
36403
36443
|
}
|
|
36404
36444
|
if (param.name) {
|
|
36405
|
-
paramString += param.name
|
|
36445
|
+
paramString += param.name;
|
|
36406
36446
|
}
|
|
36407
|
-
|
|
36408
|
-
|
|
36409
|
-
|
|
36447
|
+
if (param.typeAnnotation) {
|
|
36448
|
+
const originalType = funcType.details.parameters[index].type;
|
|
36449
|
+
const typeToPrint = getTypeToPrint(types_1.FunctionType.getEffectiveParameterType(funcType, index), originalType);
|
|
36450
|
+
const strType = isTypeUsableForPrint(typeToPrint, originalType) ? this._evaluator.printType(typeToPrint, printOptionsUsingType) : ParseTreeUtils.printExpression(param.typeAnnotation, printOptionsUsingSyntax);
|
|
36451
|
+
paramString += ": " + strType;
|
|
36410
36452
|
}
|
|
36411
|
-
if (param.
|
|
36412
|
-
paramString +=
|
|
36413
|
-
const useEllipsis = ellipsisForDefault !== null && ellipsisForDefault !== void 0 ? ellipsisForDefault : !isSimpleDefault(param.
|
|
36414
|
-
paramString += useEllipsis ? "..." : ParseTreeUtils.printExpression(param.
|
|
36453
|
+
if (param.defaultValueExpression) {
|
|
36454
|
+
paramString += param.typeAnnotation ? " = " : "=";
|
|
36455
|
+
const useEllipsis = ellipsisForDefault !== null && ellipsisForDefault !== void 0 ? ellipsisForDefault : !isSimpleDefault(param.defaultValueExpression);
|
|
36456
|
+
paramString += useEllipsis ? "..." : ParseTreeUtils.printExpression(param.defaultValueExpression, printOptionsUsingSyntax);
|
|
36415
36457
|
}
|
|
36416
|
-
if (!paramString && !param.name && param.category === 0) {
|
|
36458
|
+
if (!paramString && !param.name && param.category === 0 && index < funcType.details.parameters.length - 1) {
|
|
36417
36459
|
return "/";
|
|
36418
36460
|
}
|
|
36419
36461
|
return paramString;
|
|
36420
|
-
})
|
|
36421
|
-
let
|
|
36422
|
-
|
|
36423
|
-
|
|
36424
|
-
|
|
36425
|
-
|
|
36462
|
+
});
|
|
36463
|
+
for (let i = paramList.length - 1; i >= 0; i--) {
|
|
36464
|
+
if (paramList[i] !== "") {
|
|
36465
|
+
break;
|
|
36466
|
+
}
|
|
36467
|
+
paramList.pop();
|
|
36468
|
+
}
|
|
36469
|
+
let methodSignature = funcType.details.name + "(" + paramList.join(", ") + ")";
|
|
36470
|
+
const strReturnType = getReturnTypeStr(this._evaluator, funcType, printOptionsUsingSyntax);
|
|
36471
|
+
if (strReturnType) {
|
|
36472
|
+
methodSignature += " -> " + strReturnType;
|
|
36426
36473
|
}
|
|
36427
36474
|
return methodSignature;
|
|
36428
|
-
function
|
|
36429
|
-
|
|
36475
|
+
function getReturnTypeStr(evaluator, funcType2, printFlags) {
|
|
36476
|
+
const originalType = funcType2.details.declaredReturnType;
|
|
36477
|
+
const typeToPrint = getTypeToPrint(types_1.FunctionType.getSpecializedReturnType(funcType2), originalType);
|
|
36478
|
+
const node = funcType2.details.declaration.node;
|
|
36479
|
+
if (!node.returnTypeAnnotation && !node.functionAnnotationComment) {
|
|
36480
|
+
return void 0;
|
|
36481
|
+
}
|
|
36482
|
+
if (typeToPrint && isTypeUsableForPrint(typeToPrint, originalType)) {
|
|
36483
|
+
return evaluator.printType(typeToPrint, printOptionsUsingType);
|
|
36484
|
+
}
|
|
36485
|
+
if (node.returnTypeAnnotation) {
|
|
36486
|
+
return ParseTreeUtils.printExpression(node.returnTypeAnnotation, printFlags);
|
|
36487
|
+
}
|
|
36488
|
+
if (node.functionAnnotationComment) {
|
|
36489
|
+
return ParseTreeUtils.printExpression(node.functionAnnotationComment.returnTypeAnnotation, printFlags);
|
|
36490
|
+
}
|
|
36491
|
+
return void 0;
|
|
36492
|
+
}
|
|
36493
|
+
function isTypeUsableForPrint(effectiveType, originalType) {
|
|
36494
|
+
if (!effectiveType) {
|
|
36495
|
+
return false;
|
|
36496
|
+
}
|
|
36497
|
+
return !(0, types_1.isUnknown)(effectiveType) || (originalType === null || originalType === void 0 ? void 0 : originalType.category) === 10;
|
|
36498
|
+
}
|
|
36499
|
+
function isSimpleDefault(node) {
|
|
36500
|
+
switch (node.nodeType) {
|
|
36430
36501
|
case 40:
|
|
36431
36502
|
case 11:
|
|
36432
36503
|
case 35:
|
|
36433
36504
|
return true;
|
|
36434
36505
|
case 49:
|
|
36435
|
-
return (
|
|
36506
|
+
return (node.token.flags & 64) === 0;
|
|
36436
36507
|
case 48:
|
|
36437
|
-
return
|
|
36508
|
+
return node.strings.every(isSimpleDefault);
|
|
36438
36509
|
case 55:
|
|
36439
|
-
return isSimpleDefault(
|
|
36510
|
+
return isSimpleDefault(node.expression);
|
|
36440
36511
|
case 7:
|
|
36441
|
-
return isSimpleDefault(
|
|
36512
|
+
return isSimpleDefault(node.leftExpression) && isSimpleDefault(node.rightExpression);
|
|
36442
36513
|
default:
|
|
36443
36514
|
return false;
|
|
36444
36515
|
}
|
|
@@ -37284,7 +37355,7 @@ ${methodBody}`;
|
|
|
37284
37355
|
_addSymbolsForSymbolTable(symbolTable, includeSymbolCallback, priorWord, node, isInImport, boundObjectOrClass, completionMap) {
|
|
37285
37356
|
const insideTypeAnnotation = ParseTreeUtils.isWithinAnnotationComment(node) || ParseTreeUtils.isWithinTypeAnnotation(
|
|
37286
37357
|
node,
|
|
37287
|
-
/*requireQuotedAnnotation*/
|
|
37358
|
+
/* requireQuotedAnnotation */
|
|
37288
37359
|
false
|
|
37289
37360
|
);
|
|
37290
37361
|
symbolTable.forEach((symbol, name) => {
|
|
@@ -38512,10 +38583,25 @@ var require_hoverProvider = __commonJS({
|
|
|
38512
38583
|
}
|
|
38513
38584
|
}
|
|
38514
38585
|
}
|
|
38515
|
-
|
|
38586
|
+
let typeText;
|
|
38587
|
+
const varType = this._getType(evaluator, typeNode);
|
|
38588
|
+
if (varType.category === 5 || varType.category === 6) {
|
|
38589
|
+
typeText = (0, tooltipUtils_1.getToolTipForType)(
|
|
38590
|
+
type,
|
|
38591
|
+
label,
|
|
38592
|
+
node.value,
|
|
38593
|
+
evaluator,
|
|
38594
|
+
/* isProperty */
|
|
38595
|
+
false,
|
|
38596
|
+
functionSignatureDisplay
|
|
38597
|
+
);
|
|
38598
|
+
} else {
|
|
38599
|
+
typeText = typeVarName || node.value + this._getTypeText(typeNode, evaluator, expandTypeAlias);
|
|
38600
|
+
typeText = `(${label}) ` + typeText;
|
|
38601
|
+
}
|
|
38516
38602
|
this._addResultsPart(
|
|
38517
38603
|
parts,
|
|
38518
|
-
|
|
38604
|
+
typeText,
|
|
38519
38605
|
/* python */
|
|
38520
38606
|
true
|
|
38521
38607
|
);
|
|
@@ -50412,6 +50498,7 @@ var require_patternMatching = __commonJS({
|
|
|
50412
50498
|
}
|
|
50413
50499
|
exports.checkForUnusedPattern = checkForUnusedPattern;
|
|
50414
50500
|
function narrowTypeBasedOnSequencePattern(evaluator, type, pattern, isPositiveTest) {
|
|
50501
|
+
type = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(type);
|
|
50415
50502
|
let sequenceInfo = getSequencePatternInfo(evaluator, type, pattern.entries.length, pattern.starEntryIndex);
|
|
50416
50503
|
sequenceInfo = sequenceInfo.filter((entry) => {
|
|
50417
50504
|
if (entry.definiteNoMatch) {
|
|
@@ -52602,6 +52689,9 @@ var require_codeFlowEngine = __commonJS({
|
|
|
52602
52689
|
if (noReturnAnalysisDepth > types_1.maxTypeRecursionCount) {
|
|
52603
52690
|
return false;
|
|
52604
52691
|
}
|
|
52692
|
+
if (node.leftExpression.nodeType === 30) {
|
|
52693
|
+
return false;
|
|
52694
|
+
}
|
|
52605
52695
|
callIsNoReturnCache.set(node.id, false);
|
|
52606
52696
|
noReturnAnalysisDepth++;
|
|
52607
52697
|
try {
|
|
@@ -52882,15 +52972,77 @@ var require_constructorTransform = __commonJS({
|
|
|
52882
52972
|
const origFunctionTypeResult = evaluator.getTypeOfArgument(argList[0]);
|
|
52883
52973
|
const origFunctionType = origFunctionTypeResult.type;
|
|
52884
52974
|
evaluator.inferReturnTypeIfNecessary(origFunctionType);
|
|
52885
|
-
if (!(0, types_1.isFunction)(origFunctionType)) {
|
|
52886
|
-
return result;
|
|
52887
|
-
}
|
|
52888
52975
|
if (argList.some(
|
|
52889
52976
|
(arg) => arg.argumentCategory !== 0
|
|
52890
52977
|
/* Simple */
|
|
52891
52978
|
)) {
|
|
52892
52979
|
return result;
|
|
52893
52980
|
}
|
|
52981
|
+
if ((0, types_1.isFunction)(origFunctionType)) {
|
|
52982
|
+
const transformResult = applyPartialTransformToFunction(evaluator, errorNode, argList, callMemberType, origFunctionType);
|
|
52983
|
+
if (!transformResult) {
|
|
52984
|
+
return result;
|
|
52985
|
+
}
|
|
52986
|
+
const newPartialClass = types_1.ClassType.cloneForSymbolTableUpdate(result.returnType);
|
|
52987
|
+
newPartialClass.details.fields.set("__call__", symbol_1.Symbol.createWithType(4, transformResult.returnType));
|
|
52988
|
+
return {
|
|
52989
|
+
returnType: newPartialClass,
|
|
52990
|
+
isTypeIncomplete: result.isTypeIncomplete,
|
|
52991
|
+
argumentErrors: transformResult.argumentErrors
|
|
52992
|
+
};
|
|
52993
|
+
}
|
|
52994
|
+
if ((0, types_1.isOverloadedFunction)(origFunctionType)) {
|
|
52995
|
+
const applicableOverloads = [];
|
|
52996
|
+
let sawArgErrors = false;
|
|
52997
|
+
types_1.OverloadedFunctionType.getOverloads(origFunctionType).forEach((overload) => {
|
|
52998
|
+
const transformResult = applyPartialTransformToFunction(
|
|
52999
|
+
evaluator,
|
|
53000
|
+
/* errorNode */
|
|
53001
|
+
void 0,
|
|
53002
|
+
argList,
|
|
53003
|
+
callMemberType,
|
|
53004
|
+
overload
|
|
53005
|
+
);
|
|
53006
|
+
if (transformResult) {
|
|
53007
|
+
if (transformResult.argumentErrors) {
|
|
53008
|
+
sawArgErrors = true;
|
|
53009
|
+
} else if ((0, types_1.isFunction)(transformResult.returnType)) {
|
|
53010
|
+
applicableOverloads.push(transformResult.returnType);
|
|
53011
|
+
}
|
|
53012
|
+
}
|
|
53013
|
+
});
|
|
53014
|
+
if (applicableOverloads.length === 0) {
|
|
53015
|
+
if (sawArgErrors) {
|
|
53016
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noOverload().format({
|
|
53017
|
+
name: origFunctionType.overloads[0].details.name
|
|
53018
|
+
}), errorNode);
|
|
53019
|
+
}
|
|
53020
|
+
return result;
|
|
53021
|
+
}
|
|
53022
|
+
const newPartialClass = types_1.ClassType.cloneForSymbolTableUpdate(result.returnType);
|
|
53023
|
+
let synthesizedCallType;
|
|
53024
|
+
if (applicableOverloads.length === 1) {
|
|
53025
|
+
synthesizedCallType = applicableOverloads[0];
|
|
53026
|
+
} else {
|
|
53027
|
+
synthesizedCallType = types_1.OverloadedFunctionType.create(
|
|
53028
|
+
// Set the "overloaded" flag for each of the __call__ overloads.
|
|
53029
|
+
applicableOverloads.map((overload) => types_1.FunctionType.cloneWithNewFlags(
|
|
53030
|
+
overload,
|
|
53031
|
+
overload.details.flags | 256
|
|
53032
|
+
/* Overloaded */
|
|
53033
|
+
))
|
|
53034
|
+
);
|
|
53035
|
+
}
|
|
53036
|
+
newPartialClass.details.fields.set("__call__", symbol_1.Symbol.createWithType(4, synthesizedCallType));
|
|
53037
|
+
return {
|
|
53038
|
+
returnType: newPartialClass,
|
|
53039
|
+
isTypeIncomplete: result.isTypeIncomplete,
|
|
53040
|
+
argumentErrors: false
|
|
53041
|
+
};
|
|
53042
|
+
}
|
|
53043
|
+
return result;
|
|
53044
|
+
}
|
|
53045
|
+
function applyPartialTransformToFunction(evaluator, errorNode, argList, partialCallMemberType, origFunctionType) {
|
|
52894
53046
|
const paramMap = /* @__PURE__ */ new Map();
|
|
52895
53047
|
const paramListDetails = (0, parameterUtils_1.getParameterListDetails)(origFunctionType);
|
|
52896
53048
|
let argumentErrors = false;
|
|
@@ -52914,19 +53066,23 @@ var require_constructorTransform = __commonJS({
|
|
|
52914
53066
|
(0, typeUtils_1.makeInferenceContext)(paramType)
|
|
52915
53067
|
);
|
|
52916
53068
|
if (!evaluator.assignType(paramType, argTypeResult.type, diag, typeVarContext)) {
|
|
52917
|
-
|
|
52918
|
-
|
|
52919
|
-
|
|
52920
|
-
|
|
52921
|
-
|
|
52922
|
-
|
|
53069
|
+
if (errorNode) {
|
|
53070
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.argAssignmentParamFunction().format({
|
|
53071
|
+
argType: evaluator.printType(argTypeResult.type),
|
|
53072
|
+
paramType: evaluator.printType(paramType),
|
|
53073
|
+
functionName: origFunctionType.details.name,
|
|
53074
|
+
paramName: (_a = paramListDetails.params[paramListDetails.argsIndex].param.name) !== null && _a !== void 0 ? _a : ""
|
|
53075
|
+
}), (_b = arg.valueExpression) !== null && _b !== void 0 ? _b : errorNode);
|
|
53076
|
+
}
|
|
52923
53077
|
argumentErrors = true;
|
|
52924
53078
|
}
|
|
52925
53079
|
} else {
|
|
52926
53080
|
if (!reportedPositionalError) {
|
|
52927
|
-
|
|
52928
|
-
|
|
52929
|
-
|
|
53081
|
+
if (errorNode) {
|
|
53082
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, paramListDetails.positionParamCount === 1 ? localize_1.Localizer.Diagnostic.argPositionalExpectedOne() : localize_1.Localizer.Diagnostic.argPositionalExpectedCount().format({
|
|
53083
|
+
expected: paramListDetails.positionParamCount
|
|
53084
|
+
}), (_c = arg.valueExpression) !== null && _c !== void 0 ? _c : errorNode);
|
|
53085
|
+
}
|
|
52930
53086
|
}
|
|
52931
53087
|
reportedPositionalError = true;
|
|
52932
53088
|
argumentErrors = true;
|
|
@@ -52942,12 +53098,14 @@ var require_constructorTransform = __commonJS({
|
|
|
52942
53098
|
(0, typeUtils_1.makeInferenceContext)(paramType)
|
|
52943
53099
|
);
|
|
52944
53100
|
if (!evaluator.assignType(paramType, argTypeResult.type, diag, typeVarContext)) {
|
|
52945
|
-
|
|
52946
|
-
|
|
52947
|
-
|
|
52948
|
-
|
|
52949
|
-
|
|
52950
|
-
|
|
53101
|
+
if (errorNode) {
|
|
53102
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.argAssignmentParamFunction().format({
|
|
53103
|
+
argType: evaluator.printType(argTypeResult.type),
|
|
53104
|
+
paramType: evaluator.printType(paramType),
|
|
53105
|
+
functionName: origFunctionType.details.name,
|
|
53106
|
+
paramName
|
|
53107
|
+
}), (_e = arg.valueExpression) !== null && _e !== void 0 ? _e : errorNode);
|
|
53108
|
+
}
|
|
52951
53109
|
argumentErrors = true;
|
|
52952
53110
|
}
|
|
52953
53111
|
paramMap.set(paramName, false);
|
|
@@ -52959,7 +53117,9 @@ var require_constructorTransform = __commonJS({
|
|
|
52959
53117
|
});
|
|
52960
53118
|
if (!matchingParam) {
|
|
52961
53119
|
if (paramListDetails.kwargsIndex === void 0) {
|
|
52962
|
-
|
|
53120
|
+
if (errorNode) {
|
|
53121
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramNameMissing().format({ name: arg.name.value }), arg.name);
|
|
53122
|
+
}
|
|
52963
53123
|
argumentErrors = true;
|
|
52964
53124
|
} else {
|
|
52965
53125
|
const paramType = types_1.FunctionType.getEffectiveParameterType(origFunctionType, paramListDetails.params[paramListDetails.kwargsIndex].index);
|
|
@@ -52971,12 +53131,14 @@ var require_constructorTransform = __commonJS({
|
|
|
52971
53131
|
(0, typeUtils_1.makeInferenceContext)(paramType)
|
|
52972
53132
|
);
|
|
52973
53133
|
if (!evaluator.assignType(paramType, argTypeResult.type, diag, typeVarContext)) {
|
|
52974
|
-
|
|
52975
|
-
|
|
52976
|
-
|
|
52977
|
-
|
|
52978
|
-
|
|
52979
|
-
|
|
53134
|
+
if (errorNode) {
|
|
53135
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.argAssignmentParamFunction().format({
|
|
53136
|
+
argType: evaluator.printType(argTypeResult.type),
|
|
53137
|
+
paramType: evaluator.printType(paramType),
|
|
53138
|
+
functionName: origFunctionType.details.name,
|
|
53139
|
+
paramName: (_f = paramListDetails.params[paramListDetails.kwargsIndex].param.name) !== null && _f !== void 0 ? _f : ""
|
|
53140
|
+
}), (_g = arg.valueExpression) !== null && _g !== void 0 ? _g : errorNode);
|
|
53141
|
+
}
|
|
52980
53142
|
argumentErrors = true;
|
|
52981
53143
|
}
|
|
52982
53144
|
}
|
|
@@ -52984,7 +53146,9 @@ var require_constructorTransform = __commonJS({
|
|
|
52984
53146
|
const paramName = matchingParam.param.name;
|
|
52985
53147
|
const paramType = types_1.FunctionType.getEffectiveParameterType(origFunctionType, matchingParam.index);
|
|
52986
53148
|
if (paramMap.has(paramName)) {
|
|
52987
|
-
|
|
53149
|
+
if (errorNode) {
|
|
53150
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAlreadyAssigned().format({ name: arg.name.value }), arg.name);
|
|
53151
|
+
}
|
|
52988
53152
|
argumentErrors = true;
|
|
52989
53153
|
} else {
|
|
52990
53154
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
|
@@ -52995,12 +53159,14 @@ var require_constructorTransform = __commonJS({
|
|
|
52995
53159
|
(0, typeUtils_1.makeInferenceContext)(paramType)
|
|
52996
53160
|
);
|
|
52997
53161
|
if (!evaluator.assignType(paramType, argTypeResult.type, diag, typeVarContext)) {
|
|
52998
|
-
|
|
52999
|
-
|
|
53000
|
-
|
|
53001
|
-
|
|
53002
|
-
|
|
53003
|
-
|
|
53162
|
+
if (errorNode) {
|
|
53163
|
+
evaluator.addDiagnostic((0, analyzerNodeInfo_1.getFileInfo)(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.argAssignmentParamFunction().format({
|
|
53164
|
+
argType: evaluator.printType(argTypeResult.type),
|
|
53165
|
+
paramType: evaluator.printType(paramType),
|
|
53166
|
+
functionName: origFunctionType.details.name,
|
|
53167
|
+
paramName
|
|
53168
|
+
}), (_h = arg.valueExpression) !== null && _h !== void 0 ? _h : errorNode);
|
|
53169
|
+
}
|
|
53004
53170
|
argumentErrors = true;
|
|
53005
53171
|
}
|
|
53006
53172
|
paramMap.set(paramName, true);
|
|
@@ -53010,7 +53176,7 @@ var require_constructorTransform = __commonJS({
|
|
|
53010
53176
|
});
|
|
53011
53177
|
const specializedFunctionType = (0, typeUtils_1.applySolvedTypeVars)(origFunctionType, typeVarContext);
|
|
53012
53178
|
if (!(0, types_1.isFunction)(specializedFunctionType)) {
|
|
53013
|
-
return
|
|
53179
|
+
return void 0;
|
|
53014
53180
|
}
|
|
53015
53181
|
const updatedParamList = specializedFunctionType.details.parameters.map((param, index) => {
|
|
53016
53182
|
const specializedParam = { ...param };
|
|
@@ -53036,23 +53202,17 @@ var require_constructorTransform = __commonJS({
|
|
|
53036
53202
|
return param.category === 2;
|
|
53037
53203
|
});
|
|
53038
53204
|
const newParamList = [...unassignedParamList, ...assignedKeywordParamList, ...kwargsParam];
|
|
53039
|
-
const newCallMemberType = types_1.FunctionType.createInstance(
|
|
53040
|
-
if (
|
|
53041
|
-
types_1.FunctionType.addParameter(newCallMemberType,
|
|
53205
|
+
const newCallMemberType = types_1.FunctionType.createInstance(partialCallMemberType.details.name, partialCallMemberType.details.fullName, partialCallMemberType.details.moduleName, partialCallMemberType.details.flags, specializedFunctionType.details.docString);
|
|
53206
|
+
if (partialCallMemberType.details.parameters.length > 0) {
|
|
53207
|
+
types_1.FunctionType.addParameter(newCallMemberType, partialCallMemberType.details.parameters[0]);
|
|
53042
53208
|
}
|
|
53043
53209
|
newParamList.forEach((param) => {
|
|
53044
53210
|
types_1.FunctionType.addParameter(newCallMemberType, param);
|
|
53045
53211
|
});
|
|
53046
53212
|
newCallMemberType.details.declaredReturnType = specializedFunctionType.details.declaredReturnType ? types_1.FunctionType.getSpecializedReturnType(specializedFunctionType) : specializedFunctionType.inferredReturnType;
|
|
53047
|
-
newCallMemberType.details.declaration =
|
|
53213
|
+
newCallMemberType.details.declaration = partialCallMemberType.details.declaration;
|
|
53048
53214
|
newCallMemberType.details.typeVarScopeId = specializedFunctionType.details.typeVarScopeId;
|
|
53049
|
-
|
|
53050
|
-
newPartialClass.details.fields.set("__call__", symbol_1.Symbol.createWithType(4, newCallMemberType));
|
|
53051
|
-
return {
|
|
53052
|
-
returnType: newPartialClass,
|
|
53053
|
-
isTypeIncomplete: false,
|
|
53054
|
-
argumentErrors
|
|
53055
|
-
};
|
|
53215
|
+
return { returnType: newCallMemberType, isTypeIncomplete: false, argumentErrors };
|
|
53056
53216
|
}
|
|
53057
53217
|
}
|
|
53058
53218
|
});
|
|
@@ -54145,9 +54305,6 @@ var require_enums = __commonJS({
|
|
|
54145
54305
|
"use strict";
|
|
54146
54306
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54147
54307
|
exports.getEnumAutoValueType = exports.getTypeOfEnumMember = exports.isDeclInEnumClass = exports.transformTypeForPossibleEnumClass = exports.createEnumType = exports.isKnownEnumType = void 0;
|
|
54148
|
-
var debug_1 = require_debug2();
|
|
54149
|
-
var positionUtils_1 = require_positionUtils();
|
|
54150
|
-
var textRange_1 = require_textRange();
|
|
54151
54308
|
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
54152
54309
|
var parseTreeUtils_1 = require_parseTreeUtils();
|
|
54153
54310
|
var symbol_1 = require_symbol();
|
|
@@ -54159,19 +54316,16 @@ var require_enums = __commonJS({
|
|
|
54159
54316
|
return knownEnumTypes.some((c) => c === className);
|
|
54160
54317
|
}
|
|
54161
54318
|
exports.isKnownEnumType = isKnownEnumType;
|
|
54162
|
-
function createEnumType(errorNode, enumClass, argList) {
|
|
54319
|
+
function createEnumType(evaluator, errorNode, enumClass, argList) {
|
|
54163
54320
|
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
|
54164
|
-
let className = "enum";
|
|
54165
54321
|
if (argList.length === 0) {
|
|
54166
54322
|
return void 0;
|
|
54167
|
-
} else {
|
|
54168
|
-
const nameArg = argList[0];
|
|
54169
|
-
if (nameArg.argumentCategory === 0 && nameArg.valueExpression && nameArg.valueExpression.nodeType === 48) {
|
|
54170
|
-
className = nameArg.valueExpression.strings.map((s) => s.value).join("");
|
|
54171
|
-
} else {
|
|
54172
|
-
return void 0;
|
|
54173
|
-
}
|
|
54174
54323
|
}
|
|
54324
|
+
const nameArg = argList[0];
|
|
54325
|
+
if (nameArg.argumentCategory !== 0 || !nameArg.valueExpression || nameArg.valueExpression.nodeType !== 48 || nameArg.valueExpression.strings.length !== 1 || nameArg.valueExpression.strings[0].nodeType !== 49) {
|
|
54326
|
+
return void 0;
|
|
54327
|
+
}
|
|
54328
|
+
const className = nameArg.valueExpression.strings.map((s) => s.value).join("");
|
|
54175
54329
|
const classType = types_1.ClassType.createInstantiable(
|
|
54176
54330
|
className,
|
|
54177
54331
|
(0, parseTreeUtils_1.getClassFullName)(errorNode, fileInfo.moduleName, className),
|
|
@@ -54189,36 +54343,93 @@ var require_enums = __commonJS({
|
|
|
54189
54343
|
classFields.set("__class__", symbol_1.Symbol.createWithType(4 | 64, classType));
|
|
54190
54344
|
if (argList.length < 2) {
|
|
54191
54345
|
return void 0;
|
|
54192
|
-
}
|
|
54193
|
-
|
|
54194
|
-
|
|
54346
|
+
}
|
|
54347
|
+
const initArg = argList[1];
|
|
54348
|
+
if (initArg.argumentCategory !== 0 || !initArg.valueExpression) {
|
|
54349
|
+
return void 0;
|
|
54350
|
+
}
|
|
54351
|
+
const intClassType = evaluator.getBuiltInType(errorNode, "int");
|
|
54352
|
+
if (!intClassType || !(0, types_1.isInstantiableClass)(intClassType)) {
|
|
54353
|
+
return void 0;
|
|
54354
|
+
}
|
|
54355
|
+
const classInstanceType = types_1.ClassType.cloneAsInstance(classType);
|
|
54356
|
+
if (initArg.valueExpression.nodeType === 48) {
|
|
54357
|
+
if (!initArg.valueExpression.strings.every(
|
|
54358
|
+
(str) => str.nodeType === 49
|
|
54359
|
+
/* String */
|
|
54360
|
+
)) {
|
|
54195
54361
|
return void 0;
|
|
54196
|
-
}
|
|
54197
|
-
|
|
54198
|
-
|
|
54199
|
-
|
|
54200
|
-
|
|
54201
|
-
|
|
54202
|
-
|
|
54203
|
-
|
|
54204
|
-
|
|
54205
|
-
|
|
54206
|
-
|
|
54207
|
-
|
|
54208
|
-
|
|
54209
|
-
|
|
54210
|
-
|
|
54211
|
-
|
|
54212
|
-
|
|
54213
|
-
|
|
54214
|
-
|
|
54215
|
-
|
|
54216
|
-
|
|
54217
|
-
|
|
54218
|
-
|
|
54219
|
-
|
|
54362
|
+
}
|
|
54363
|
+
const initStr = initArg.valueExpression.strings.map((s) => s.value).join("").trim();
|
|
54364
|
+
const entryNames = initStr.split(/[\s,]+/);
|
|
54365
|
+
for (const [index, entryName] of entryNames.entries()) {
|
|
54366
|
+
if (!entryName) {
|
|
54367
|
+
return void 0;
|
|
54368
|
+
}
|
|
54369
|
+
const valueType = types_1.ClassType.cloneWithLiteral(types_1.ClassType.cloneAsInstance(intClassType), index + 1);
|
|
54370
|
+
const enumLiteral = new types_1.EnumLiteral(classType.details.fullName, classType.details.name, entryName, valueType);
|
|
54371
|
+
const newSymbol = symbol_1.Symbol.createWithType(4, types_1.ClassType.cloneWithLiteral(classInstanceType, enumLiteral));
|
|
54372
|
+
classFields.set(entryName, newSymbol);
|
|
54373
|
+
}
|
|
54374
|
+
return classType;
|
|
54375
|
+
}
|
|
54376
|
+
if (initArg.valueExpression.nodeType === 31 || initArg.valueExpression.nodeType === 52) {
|
|
54377
|
+
const entries = initArg.valueExpression.nodeType === 31 ? initArg.valueExpression.entries : initArg.valueExpression.expressions;
|
|
54378
|
+
if (entries.length === 0) {
|
|
54379
|
+
return void 0;
|
|
54380
|
+
}
|
|
54381
|
+
let isSimpleString = false;
|
|
54382
|
+
for (const [index, entry] of entries.entries()) {
|
|
54383
|
+
if (index === 0) {
|
|
54384
|
+
isSimpleString = entry.nodeType === 48;
|
|
54385
|
+
}
|
|
54386
|
+
let nameNode;
|
|
54387
|
+
let valueType;
|
|
54388
|
+
if (entry.nodeType === 48) {
|
|
54389
|
+
if (!isSimpleString) {
|
|
54390
|
+
return void 0;
|
|
54220
54391
|
}
|
|
54221
|
-
|
|
54392
|
+
nameNode = entry;
|
|
54393
|
+
valueType = types_1.ClassType.cloneWithLiteral(types_1.ClassType.cloneAsInstance(intClassType), index + 1);
|
|
54394
|
+
} else if (entry.nodeType === 52) {
|
|
54395
|
+
if (isSimpleString) {
|
|
54396
|
+
return void 0;
|
|
54397
|
+
}
|
|
54398
|
+
if (entry.expressions.length !== 2) {
|
|
54399
|
+
return void 0;
|
|
54400
|
+
}
|
|
54401
|
+
nameNode = entry.expressions[0];
|
|
54402
|
+
valueType = evaluator.getTypeOfExpression(entry.expressions[1]).type;
|
|
54403
|
+
} else {
|
|
54404
|
+
return void 0;
|
|
54405
|
+
}
|
|
54406
|
+
if (nameNode.nodeType !== 48 || nameNode.strings.length !== 1 || nameNode.strings[0].nodeType !== 49) {
|
|
54407
|
+
return void 0;
|
|
54408
|
+
}
|
|
54409
|
+
const entryName = nameNode.strings[0].value;
|
|
54410
|
+
const enumLiteral = new types_1.EnumLiteral(classType.details.fullName, classType.details.name, entryName, valueType);
|
|
54411
|
+
const newSymbol = symbol_1.Symbol.createWithType(4, types_1.ClassType.cloneWithLiteral(classInstanceType, enumLiteral));
|
|
54412
|
+
classFields.set(entryName, newSymbol);
|
|
54413
|
+
}
|
|
54414
|
+
}
|
|
54415
|
+
if (initArg.valueExpression.nodeType === 15) {
|
|
54416
|
+
const entries = initArg.valueExpression.entries;
|
|
54417
|
+
if (entries.length === 0) {
|
|
54418
|
+
return void 0;
|
|
54419
|
+
}
|
|
54420
|
+
for (const entry of entries) {
|
|
54421
|
+
if (entry.nodeType !== 17) {
|
|
54422
|
+
return void 0;
|
|
54423
|
+
}
|
|
54424
|
+
const nameNode = entry.keyExpression;
|
|
54425
|
+
const valueType = evaluator.getTypeOfExpression(entry.valueExpression).type;
|
|
54426
|
+
if (nameNode.nodeType !== 48 || nameNode.strings.length !== 1 || nameNode.strings[0].nodeType !== 49) {
|
|
54427
|
+
return void 0;
|
|
54428
|
+
}
|
|
54429
|
+
const entryName = nameNode.strings[0].value;
|
|
54430
|
+
const enumLiteral = new types_1.EnumLiteral(classType.details.fullName, classType.details.name, entryName, valueType);
|
|
54431
|
+
const newSymbol = symbol_1.Symbol.createWithType(4, types_1.ClassType.cloneWithLiteral(classInstanceType, enumLiteral));
|
|
54432
|
+
classFields.set(entryName, newSymbol);
|
|
54222
54433
|
}
|
|
54223
54434
|
}
|
|
54224
54435
|
return classType;
|
|
@@ -60429,11 +60640,16 @@ var require_typeEvaluator = __commonJS({
|
|
|
60429
60640
|
}
|
|
60430
60641
|
function getTypeOfCall(node, inferenceContext, flags) {
|
|
60431
60642
|
var _a;
|
|
60432
|
-
|
|
60433
|
-
|
|
60434
|
-
|
|
60435
|
-
|
|
60436
|
-
|
|
60643
|
+
let baseTypeResult;
|
|
60644
|
+
if (node.leftExpression.nodeType === 30) {
|
|
60645
|
+
baseTypeResult = getTypeOfLambdaForCall(node, inferenceContext);
|
|
60646
|
+
} else {
|
|
60647
|
+
baseTypeResult = getTypeOfExpression(
|
|
60648
|
+
node.leftExpression,
|
|
60649
|
+
2
|
|
60650
|
+
/* DoNotSpecialize */
|
|
60651
|
+
);
|
|
60652
|
+
}
|
|
60437
60653
|
const argList = node.arguments.map((arg) => {
|
|
60438
60654
|
const functionArg = {
|
|
60439
60655
|
valueExpression: arg.valueExpression,
|
|
@@ -60502,6 +60718,50 @@ var require_typeEvaluator = __commonJS({
|
|
|
60502
60718
|
}
|
|
60503
60719
|
return typeResult;
|
|
60504
60720
|
}
|
|
60721
|
+
function getTypeOfLambdaForCall(node, inferenceContext) {
|
|
60722
|
+
(0, debug_1.assert)(
|
|
60723
|
+
node.leftExpression.nodeType === 30
|
|
60724
|
+
/* Lambda */
|
|
60725
|
+
);
|
|
60726
|
+
const expectedType = types_1.FunctionType.createSynthesizedInstance("");
|
|
60727
|
+
expectedType.details.declaredReturnType = inferenceContext ? inferenceContext.expectedType : types_1.UnknownType.create();
|
|
60728
|
+
let isArgTypeIncomplete = false;
|
|
60729
|
+
node.arguments.forEach((arg, index) => {
|
|
60730
|
+
const argTypeResult = getTypeOfExpression(arg.valueExpression);
|
|
60731
|
+
if (argTypeResult.isIncomplete) {
|
|
60732
|
+
isArgTypeIncomplete = true;
|
|
60733
|
+
}
|
|
60734
|
+
types_1.FunctionType.addParameter(expectedType, {
|
|
60735
|
+
category: 0,
|
|
60736
|
+
name: `p${index.toString()}`,
|
|
60737
|
+
type: argTypeResult.type,
|
|
60738
|
+
hasDeclaredType: true
|
|
60739
|
+
});
|
|
60740
|
+
});
|
|
60741
|
+
const lambdaParams = node.leftExpression.parameters;
|
|
60742
|
+
if (lambdaParams.length > 0) {
|
|
60743
|
+
const lastParam = lambdaParams[lambdaParams.length - 1];
|
|
60744
|
+
if (lastParam.category === 0 && !lastParam.name) {
|
|
60745
|
+
types_1.FunctionType.addParameter(expectedType, {
|
|
60746
|
+
category: 0,
|
|
60747
|
+
name: "",
|
|
60748
|
+
type: types_1.UnknownType.create()
|
|
60749
|
+
});
|
|
60750
|
+
}
|
|
60751
|
+
}
|
|
60752
|
+
function getLambdaType() {
|
|
60753
|
+
return getTypeOfExpression(node.leftExpression, 2, (0, typeUtils_1.makeInferenceContext)(expectedType));
|
|
60754
|
+
}
|
|
60755
|
+
let typeResult = isArgTypeIncomplete || speculativeTypeTracker.isSpeculative(node) || (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.isTypeIncomplete) ? useSpeculativeMode(node.leftExpression, getLambdaType) : getLambdaType();
|
|
60756
|
+
if (typeResult.typeErrors) {
|
|
60757
|
+
typeResult = getTypeOfExpression(
|
|
60758
|
+
node.leftExpression,
|
|
60759
|
+
2
|
|
60760
|
+
/* DoNotSpecialize */
|
|
60761
|
+
);
|
|
60762
|
+
}
|
|
60763
|
+
return typeResult;
|
|
60764
|
+
}
|
|
60505
60765
|
function getTypeOfAssertType(node, inferenceContext) {
|
|
60506
60766
|
if (node.arguments.length !== 2 || node.arguments[0].argumentCategory !== 0 || node.arguments[0].name !== void 0 || node.arguments[0].argumentCategory !== 0 || node.arguments[1].name !== void 0) {
|
|
60507
60767
|
addError(localize_1.Localizer.Diagnostic.assertTypeArgs(), node);
|
|
@@ -60753,6 +61013,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
60753
61013
|
const argTypeOverride = expandedArgTypes[expandedTypesIndex];
|
|
60754
61014
|
const hasArgTypeOverride = argTypeOverride.some((a) => a !== void 0);
|
|
60755
61015
|
let possibleMatchResults = [];
|
|
61016
|
+
let possibleMatchInvolvesIncompleteUnknown = false;
|
|
60756
61017
|
isDefinitiveMatchFound = false;
|
|
60757
61018
|
for (let overloadIndex = 0; overloadIndex < argParamMatches.length; overloadIndex++) {
|
|
60758
61019
|
const overload = argParamMatches[overloadIndex].overload;
|
|
@@ -60799,8 +61060,11 @@ var require_typeEvaluator = __commonJS({
|
|
|
60799
61060
|
argResults: (_b = callResult.argResults) !== null && _b !== void 0 ? _b : []
|
|
60800
61061
|
};
|
|
60801
61062
|
matchedOverloads.push(matchedOverloadInfo);
|
|
60802
|
-
if (callResult.
|
|
61063
|
+
if (callResult.anyOrUnknownArgument) {
|
|
60803
61064
|
possibleMatchResults.push(matchedOverloadInfo);
|
|
61065
|
+
if ((0, typeUtils_1.isIncompleteUnknown)(callResult.anyOrUnknownArgument)) {
|
|
61066
|
+
possibleMatchInvolvesIncompleteUnknown = true;
|
|
61067
|
+
}
|
|
60804
61068
|
} else {
|
|
60805
61069
|
returnTypes.push(callResult.returnType);
|
|
60806
61070
|
isDefinitiveMatchFound = true;
|
|
@@ -60832,7 +61096,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
60832
61096
|
});
|
|
60833
61097
|
dedupedMatchResults = dedupedMatchResults.filter((t) => !(0, types_1.isNever)(t));
|
|
60834
61098
|
const combinedTypes = (0, types_1.combineTypes)(dedupedMatchResults);
|
|
60835
|
-
returnTypes.push(dedupedMatchResults.length > 1 ? types_1.UnknownType.createPossibleType(combinedTypes) : combinedTypes);
|
|
61099
|
+
returnTypes.push(dedupedMatchResults.length > 1 ? types_1.UnknownType.createPossibleType(combinedTypes, possibleMatchInvolvesIncompleteUnknown) : combinedTypes);
|
|
60836
61100
|
}
|
|
60837
61101
|
}
|
|
60838
61102
|
if (!matchedOverload) {
|
|
@@ -60851,7 +61115,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
60851
61115
|
}
|
|
60852
61116
|
return {
|
|
60853
61117
|
argumentErrors: finalCallResult.argumentErrors,
|
|
60854
|
-
|
|
61118
|
+
anyOrUnknownArgument: finalCallResult.anyOrUnknownArgument,
|
|
60855
61119
|
returnType: (0, types_1.combineTypes)(returnTypes),
|
|
60856
61120
|
isTypeIncomplete,
|
|
60857
61121
|
specializedInitSelfType: finalCallResult.specializedInitSelfType,
|
|
@@ -61486,7 +61750,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
61486
61750
|
return types_1.AnyType.create();
|
|
61487
61751
|
}
|
|
61488
61752
|
if ((0, types_1.isClass)(unexpandedSubtype) && (0, enums_1.isKnownEnumType)(className)) {
|
|
61489
|
-
return (_d = (0, enums_1.createEnumType)(errorNode, expandedSubtype, argList)) !== null && _d !== void 0 ? _d : types_1.UnknownType.create();
|
|
61753
|
+
return (_d = (0, enums_1.createEnumType)(evaluatorInterface, errorNode, expandedSubtype, argList)) !== null && _d !== void 0 ? _d : types_1.UnknownType.create();
|
|
61490
61754
|
}
|
|
61491
61755
|
if (className === "TypedDict") {
|
|
61492
61756
|
return (0, typedDicts_1.createTypedDictType)(evaluatorInterface, errorNode, expandedSubtype, argList);
|
|
@@ -62344,7 +62608,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62344
62608
|
let isTypeIncomplete = matchResults.isTypeIncomplete;
|
|
62345
62609
|
let argumentErrors = false;
|
|
62346
62610
|
let specializedInitSelfType;
|
|
62347
|
-
let
|
|
62611
|
+
let anyOrUnknownArgument;
|
|
62348
62612
|
const typeCondition = (0, typeUtils_1.getTypeCondition)(type);
|
|
62349
62613
|
if (type.boundTypeVarScopeId) {
|
|
62350
62614
|
if (type.preBoundFlags !== void 0 && type.boundToType && (0, typeUtils_1.requiresSpecialization)(type.boundToType)) {
|
|
@@ -62386,7 +62650,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62386
62650
|
skipUnknownArgCheck,
|
|
62387
62651
|
/* skipOverloadArg */
|
|
62388
62652
|
i === 0,
|
|
62389
|
-
/*
|
|
62653
|
+
/* isFirstPass */
|
|
62390
62654
|
passCount > 1 && i === 0,
|
|
62391
62655
|
typeCondition
|
|
62392
62656
|
);
|
|
@@ -62416,7 +62680,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62416
62680
|
skipUnknownArgCheck,
|
|
62417
62681
|
/* skipOverloadArg */
|
|
62418
62682
|
false,
|
|
62419
|
-
/*
|
|
62683
|
+
/* isFirstPass */
|
|
62420
62684
|
false,
|
|
62421
62685
|
typeCondition
|
|
62422
62686
|
);
|
|
@@ -62431,7 +62695,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62431
62695
|
condition = (_a = types_1.TypeCondition.combine(condition, argResult.condition)) !== null && _a !== void 0 ? _a : [];
|
|
62432
62696
|
}
|
|
62433
62697
|
if ((0, types_1.isAnyOrUnknown)(argResult.argType)) {
|
|
62434
|
-
|
|
62698
|
+
anyOrUnknownArgument = anyOrUnknownArgument ? (0, typeUtils_1.preserveUnknown)(argResult.argType, anyOrUnknownArgument) : argResult.argType;
|
|
62435
62699
|
}
|
|
62436
62700
|
if (type.details.paramSpec) {
|
|
62437
62701
|
if (argParam.argument.argumentCategory === 1) {
|
|
@@ -62520,7 +62784,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62520
62784
|
return {
|
|
62521
62785
|
argumentErrors,
|
|
62522
62786
|
argResults,
|
|
62523
|
-
|
|
62787
|
+
anyOrUnknownArgument,
|
|
62524
62788
|
returnType: specializedReturnType,
|
|
62525
62789
|
isTypeIncomplete,
|
|
62526
62790
|
activeParam: matchResults.activeParam,
|
|
@@ -62528,14 +62792,11 @@ var require_typeEvaluator = __commonJS({
|
|
|
62528
62792
|
overloadsUsedForCall: argumentErrors ? [] : [type]
|
|
62529
62793
|
};
|
|
62530
62794
|
}
|
|
62531
|
-
function adjustCallableReturnType(
|
|
62532
|
-
if ((0, types_1.isFunction)(
|
|
62533
|
-
|
|
62534
|
-
...type.details,
|
|
62535
|
-
typeVarScopeId: types_1.WildcardTypeVarScopeId
|
|
62536
|
-
};
|
|
62795
|
+
function adjustCallableReturnType(returnType) {
|
|
62796
|
+
if ((0, types_1.isFunction)(returnType) && !returnType.details.name) {
|
|
62797
|
+
return types_1.FunctionType.cloneWithNewTypeVarScopeId(returnType, types_1.WildcardTypeVarScopeId);
|
|
62537
62798
|
}
|
|
62538
|
-
return
|
|
62799
|
+
return returnType;
|
|
62539
62800
|
}
|
|
62540
62801
|
function validateFunctionArguments(errorNode, argList, typeResult, typeVarContext, skipUnknownArgCheck = false, inferenceContext) {
|
|
62541
62802
|
const matchResults = matchFunctionArgumentsToParameters(errorNode, argList, typeResult, 0);
|
|
@@ -62653,7 +62914,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62653
62914
|
false,
|
|
62654
62915
|
/* skipOverloadArg */
|
|
62655
62916
|
false,
|
|
62656
|
-
/*
|
|
62917
|
+
/* isFirstPass */
|
|
62657
62918
|
false,
|
|
62658
62919
|
conditionFilter
|
|
62659
62920
|
);
|
|
@@ -62682,7 +62943,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62682
62943
|
}
|
|
62683
62944
|
return !reportedArgError;
|
|
62684
62945
|
}
|
|
62685
|
-
function validateArgType(argParam, typeVarContext, signatureTracker, typeResult, skipUnknownCheck, skipOverloadArg,
|
|
62946
|
+
function validateArgType(argParam, typeVarContext, signatureTracker, typeResult, skipUnknownCheck, skipOverloadArg, isFirstPass, conditionFilter) {
|
|
62686
62947
|
var _a;
|
|
62687
62948
|
let argType;
|
|
62688
62949
|
let expectedTypeDiag;
|
|
@@ -62691,8 +62952,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
62691
62952
|
const functionName = typeResult === null || typeResult === void 0 ? void 0 : typeResult.type.details.name;
|
|
62692
62953
|
if (argParam.argument.valueExpression) {
|
|
62693
62954
|
let expectedType;
|
|
62694
|
-
if (!(0, types_1.isTypeVar)(argParam.paramType) || argParam.paramType.scopeId !== (typeResult === null || typeResult === void 0 ? void 0 : typeResult.type.details.typeVarScopeId)) {
|
|
62695
|
-
expectedType = (0, typeUtils_1.applySolvedTypeVars)(argParam.paramType, typeVarContext, {
|
|
62955
|
+
if (!isFirstPass || !(0, types_1.isTypeVar)(argParam.paramType) || argParam.paramType.scopeId !== (typeResult === null || typeResult === void 0 ? void 0 : typeResult.type.details.typeVarScopeId)) {
|
|
62956
|
+
expectedType = (0, typeUtils_1.applySolvedTypeVars)(argParam.paramType, typeVarContext, {
|
|
62957
|
+
useNarrowBoundOnly: isFirstPass
|
|
62958
|
+
});
|
|
62696
62959
|
}
|
|
62697
62960
|
if (expectedType && (0, types_1.isUnknown)(expectedType)) {
|
|
62698
62961
|
expectedType = void 0;
|
|
@@ -64664,11 +64927,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
64664
64927
|
}
|
|
64665
64928
|
return void 0;
|
|
64666
64929
|
});
|
|
64667
|
-
const minLambdaParamCount = node.parameters.filter((param) => param.category === 0 && param.defaultValue === void 0).length;
|
|
64668
|
-
const maxLambdaParamCount = node.parameters.filter(
|
|
64669
|
-
(param) => param.category === 0
|
|
64670
|
-
/* Simple */
|
|
64671
|
-
).length;
|
|
64930
|
+
const minLambdaParamCount = node.parameters.filter((param) => param.category === 0 && !!param.name && param.defaultValue === void 0).length;
|
|
64931
|
+
const maxLambdaParamCount = node.parameters.filter((param) => param.category === 0 && !!param.name).length;
|
|
64672
64932
|
expectedFunctionTypes = expectedFunctionTypes.filter((functionType2) => {
|
|
64673
64933
|
const functionParamCount = functionType2.details.parameters.filter((param) => !!param.name && !param.hasDefault).length;
|
|
64674
64934
|
const hasVarArgs = functionType2.details.parameters.some(
|
|
@@ -68306,6 +68566,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
68306
68566
|
nodeToEvaluate = parent2;
|
|
68307
68567
|
continue;
|
|
68308
68568
|
}
|
|
68569
|
+
if (parent2.nodeType === 9 && nodeToEvaluate.nodeType === 30) {
|
|
68570
|
+
nodeToEvaluate = parent2;
|
|
68571
|
+
continue;
|
|
68572
|
+
}
|
|
68309
68573
|
flags = 2;
|
|
68310
68574
|
break;
|
|
68311
68575
|
}
|
|
@@ -72709,6 +72973,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
72709
72973
|
if (options === null || options === void 0 ? void 0 : options.useTypingUnpack) {
|
|
72710
72974
|
flags |= 512;
|
|
72711
72975
|
}
|
|
72976
|
+
if (options === null || options === void 0 ? void 0 : options.printUnknownWithAny) {
|
|
72977
|
+
flags |= 1;
|
|
72978
|
+
}
|
|
72979
|
+
if (options === null || options === void 0 ? void 0 : options.omitTypeArgumentsIfUnknown) {
|
|
72980
|
+
flags |= 2;
|
|
72981
|
+
}
|
|
72712
72982
|
return TypePrinter.printType(type, flags, getFunctionEffectiveReturnType);
|
|
72713
72983
|
}
|
|
72714
72984
|
function parseStringAsTypeAnnotation(node) {
|
|
@@ -100978,12 +101248,12 @@ var PythonCodeActionProvider = class {
|
|
|
100978
101248
|
}
|
|
100979
101249
|
}
|
|
100980
101250
|
if (diag.fix) {
|
|
100981
|
-
const title = `Fix: ${diag.message.split(":")[0]}`;
|
|
100982
101251
|
const action = {
|
|
100983
|
-
|
|
101252
|
+
// @ts-ignore
|
|
101253
|
+
title: diag.fix.title,
|
|
100984
101254
|
kind: import_coc3.CodeActionKind.QuickFix,
|
|
100985
101255
|
// @ts-ignore
|
|
100986
|
-
edit: diag.fix
|
|
101256
|
+
edit: diag.fix.edit
|
|
100987
101257
|
};
|
|
100988
101258
|
return [action];
|
|
100989
101259
|
}
|
|
@@ -102441,7 +102711,8 @@ var MyPy = class extends BaseLinter {
|
|
|
102441
102711
|
super(info, outputChannel, COLUMN_OFF_SET2);
|
|
102442
102712
|
}
|
|
102443
102713
|
async runLinter(document, cancellation) {
|
|
102444
|
-
const
|
|
102714
|
+
const args = ["--python-executable", this.pythonSettings.pythonPath, import_coc17.Uri.parse(document.uri).fsPath];
|
|
102715
|
+
const messages = await this.run(args, document, cancellation, REGEX2);
|
|
102445
102716
|
messages.forEach((msg) => {
|
|
102446
102717
|
msg.severity = this.parseMessagesSeverity(msg.type, this.pythonSettings.linting.mypyCategorySeverity);
|
|
102447
102718
|
msg.code = msg.type;
|
|
@@ -102741,12 +103012,31 @@ var Ruff = class extends BaseLinter {
|
|
|
102741
103012
|
if (!fix)
|
|
102742
103013
|
return null;
|
|
102743
103014
|
const u = import_coc25.Uri.parse(filename).toString();
|
|
102744
|
-
|
|
102745
|
-
|
|
102746
|
-
|
|
102747
|
-
|
|
102748
|
-
}
|
|
102749
|
-
|
|
103015
|
+
if (fix.edits && fix.edits.length) {
|
|
103016
|
+
const changes = fix.edits.map((edit) => {
|
|
103017
|
+
const range = import_coc25.Range.create(edit.location.row - 1, edit.location.column, edit.end_location.row - 1, edit.end_location.column);
|
|
103018
|
+
return import_coc25.TextEdit.replace(range, edit.content);
|
|
103019
|
+
});
|
|
103020
|
+
return {
|
|
103021
|
+
title: `Ruff: ${fix.message}`,
|
|
103022
|
+
edit: {
|
|
103023
|
+
changes: {
|
|
103024
|
+
[u]: changes
|
|
103025
|
+
}
|
|
103026
|
+
}
|
|
103027
|
+
};
|
|
103028
|
+
} else if (fix.location && fix.end_location) {
|
|
103029
|
+
const range = import_coc25.Range.create(fix.location.row - 1, fix.location.column, fix.end_location.row - 1, fix.end_location.column);
|
|
103030
|
+
return {
|
|
103031
|
+
title: `Ruff: ${fix.message}`,
|
|
103032
|
+
edit: {
|
|
103033
|
+
changes: {
|
|
103034
|
+
[u]: [import_coc25.TextEdit.replace(range, fix.content || "")]
|
|
103035
|
+
}
|
|
103036
|
+
}
|
|
103037
|
+
};
|
|
103038
|
+
}
|
|
103039
|
+
return null;
|
|
102750
103040
|
}
|
|
102751
103041
|
async parseMessages(output) {
|
|
102752
103042
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coc-pyright",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.304",
|
|
4
4
|
"description": "Pyright extension for coc.nvim, static type checker for Python",
|
|
5
5
|
"author": "Heyward Fann <fannheyward@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/which": "^2.0.0",
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
|
46
46
|
"@typescript-eslint/parser": "^5.6.0",
|
|
47
|
-
"@zzzen/pyright-internal": "^1.2.0-dev.
|
|
47
|
+
"@zzzen/pyright-internal": "^1.2.0-dev.20230416",
|
|
48
48
|
"coc.nvim": "^0.0.82",
|
|
49
49
|
"diff-match-patch": "^1.0.5",
|
|
50
50
|
"esbuild": "^0.17.10",
|
|
@@ -1572,6 +1572,6 @@
|
|
|
1572
1572
|
]
|
|
1573
1573
|
},
|
|
1574
1574
|
"dependencies": {
|
|
1575
|
-
"pyright": "^1.1.
|
|
1575
|
+
"pyright": "^1.1.304"
|
|
1576
1576
|
}
|
|
1577
1577
|
}
|