@zzzen/pyright-internal 1.2.0-dev.20240414 → 1.2.0-dev.20240428
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/dist/analyzer/analyzerNodeInfo.d.ts +1 -4
- package/dist/analyzer/analyzerNodeInfo.js +1 -11
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/binder.d.ts +0 -2
- package/dist/analyzer/binder.js +42 -66
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +57 -17
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constructors.js +53 -23
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +1 -1
- package/dist/analyzer/dataClasses.js +26 -11
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/deprecatedSymbols.js +2 -4
- package/dist/analyzer/deprecatedSymbols.js.map +1 -1
- package/dist/analyzer/namedTuples.js +0 -8
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +10 -10
- package/dist/analyzer/parseTreeUtils.d.ts +6 -3
- package/dist/analyzer/parseTreeUtils.js +75 -46
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/protocols.js +32 -13
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/scope.d.ts +14 -7
- package/dist/analyzer/scope.js +25 -16
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.js +3 -3
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +0 -2
- package/dist/analyzer/service.js +1 -4
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +3 -1
- package/dist/analyzer/typeEvaluator.js +250 -205
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +5 -1
- package/dist/analyzer/typeEvaluatorWithTracker.js +4 -2
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +35 -110
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.js +5 -3
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +4 -6
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.js +10 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundThreadBase.js +4 -2
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.d.ts +5 -0
- package/dist/commands/dumpFileDebugInfoCommand.js +83 -74
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/console.d.ts +12 -1
- package/dist/common/console.js +22 -3
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.d.ts +5 -0
- package/dist/common/core.js +8 -1
- package/dist/common/core.js.map +1 -1
- package/dist/common/diagnostic.d.ts +4 -0
- package/dist/common/diagnostic.js +10 -4
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +2 -2
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/fileSystem.d.ts +0 -1
- package/dist/common/fileSystem.js +1 -1
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/languageServerInterface.d.ts +6 -3
- package/dist/common/languageServerInterface.js +11 -0
- package/dist/common/languageServerInterface.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +35 -1
- package/dist/common/realFileSystem.js +4 -1
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/uri/uri.d.ts +4 -0
- package/dist/common/uri/uri.js +11 -4
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +4 -1
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +12 -8
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +1 -1
- package/dist/languageService/referencesProvider.js +3 -2
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +3 -0
- package/dist/localization/localize.js +1 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +3 -0
- package/dist/localization/package.nls.de.json +3 -0
- package/dist/localization/package.nls.en-us.json +1 -0
- package/dist/localization/package.nls.es.json +3 -0
- package/dist/localization/package.nls.fr.json +3 -0
- package/dist/localization/package.nls.it.json +3 -0
- package/dist/localization/package.nls.ja.json +3 -0
- package/dist/localization/package.nls.ko.json +3 -0
- package/dist/localization/package.nls.pl.json +3 -0
- package/dist/localization/package.nls.pt-br.json +3 -0
- package/dist/localization/package.nls.qps-ploc.json +3 -0
- package/dist/localization/package.nls.ru.json +3 -0
- package/dist/localization/package.nls.tr.json +3 -0
- package/dist/localization/package.nls.zh-cn.json +3 -0
- package/dist/localization/package.nls.zh-tw.json +3 -0
- package/dist/parser/parseNodes.d.ts +2 -2
- package/dist/tests/checker.test.js +8 -0
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/config.test.js +11 -0
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/fourslash/{completions.importDunderNames.fourslash.js → completions.import.dunderNames.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.dunderNames.fourslash.js.map +1 -0
- package/dist/tests/fourslash/{completions.importsDuplicates.fourslash.js → completions.import.duplicates.fourslash.js} +1 -1
- package/dist/tests/fourslash/{completions.importsDuplicates.fourslash.js.map → completions.import.duplicates.fourslash.js.map} +1 -1
- package/dist/tests/fourslash/completions.import.exactMatch.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.import.exactMatch.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.import.excludeAlreadyImported.fourslash.js +14 -0
- package/dist/tests/fourslash/completions.import.excludeAlreadyImported.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.d.ts +1 -0
- package/dist/tests/fourslash/{completions.importInterimFile.fourslash.disabled.js → completions.import.interimFile.fourslash.disabled.js} +1 -1
- package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.js.map +1 -0
- package/dist/tests/fourslash/{completions.importPrivateNoPytyped.fourslash.js → completions.import.privateNoPytyped.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.privateNoPytyped.fourslash.js.map +1 -0
- package/dist/tests/fourslash/{completions.importPytyped.fourslash.js → completions.import.pytyped.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.pytyped.fourslash.js.map +1 -0
- package/dist/tests/fourslash/{completions.importPytypedLocal.fourslash.js → completions.import.pytypedLocal.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.pytypedLocal.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.import.submodule.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/{completions.importSubmodule.fourslash.js → completions.import.submodule.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.submodule.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.js +1 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +2 -1
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +1 -1
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator2.test.js +4 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +5 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +2 -2
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +3 -1
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.js.map +0 -1
- package/dist/tests/fourslash/completions.importInterimFile.fourslash.disabled.js.map +0 -1
- package/dist/tests/fourslash/completions.importPrivateNoPytyped.fourslash.js.map +0 -1
- package/dist/tests/fourslash/completions.importPytyped.fourslash.js.map +0 -1
- package/dist/tests/fourslash/completions.importPytypedLocal.fourslash.js.map +0 -1
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.js.map +0 -1
- /package/dist/tests/fourslash/{completions.importDunderNames.fourslash.d.ts → completions.import.dunderNames.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importPrivateNoPytyped.fourslash.d.ts → completions.import.duplicates.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importInterimFile.fourslash.disabled.d.ts → completions.import.exactMatch.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importSubmodule.fourslash.d.ts → completions.import.excludeAlreadyImported.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importPytyped.fourslash.d.ts → completions.import.privateNoPytyped.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importPytypedLocal.fourslash.d.ts → completions.import.pytyped.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importsDuplicates.fourslash.d.ts → completions.import.pytypedLocal.fourslash.d.ts} +0 -0
package/dist/analyzer/checker.js
CHANGED
@@ -397,7 +397,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
397
397
|
// This signifies an incomplete stub file that obscures type errors.
|
398
398
|
if (this._fileInfo.isStubFile && node.name.value === '__getattr__') {
|
399
399
|
const scope = (0, scopeUtils_1.getScopeForNode)(node);
|
400
|
-
if ((scope === null || scope === void 0 ? void 0 : scope.type) ===
|
400
|
+
if ((scope === null || scope === void 0 ? void 0 : scope.type) === 4 /* ScopeType.Module */) {
|
401
401
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompleteStub, localize_1.LocMessage.stubUsesGetAttr(), node.name);
|
402
402
|
}
|
403
403
|
}
|
@@ -741,9 +741,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
741
741
|
if ((0, types_1.isClassInstance)(annotationType) && types_1.ClassType.isBuiltIn(annotationType, 'TypeAlias')) {
|
742
742
|
const scope = (0, scopeUtils_1.getScopeForNode)(node);
|
743
743
|
if (scope) {
|
744
|
-
if (scope.type !==
|
745
|
-
scope.type !==
|
746
|
-
scope.type !==
|
744
|
+
if (scope.type !== 3 /* ScopeType.Class */ &&
|
745
|
+
scope.type !== 4 /* ScopeType.Module */ &&
|
746
|
+
scope.type !== 5 /* ScopeType.Builtin */) {
|
747
747
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasNotInModuleOrClass(), node.leftExpression.typeAnnotation);
|
748
748
|
}
|
749
749
|
}
|
@@ -1043,12 +1043,41 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1043
1043
|
return true;
|
1044
1044
|
}
|
1045
1045
|
visitTypeParameter(node) {
|
1046
|
+
var _a, _b, _c, _d;
|
1047
|
+
// Verify that there are no live type variables with the same
|
1048
|
+
// name in outer scopes.
|
1049
|
+
let curNode = (_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent;
|
1050
|
+
let foundDuplicate = false;
|
1051
|
+
while (curNode) {
|
1052
|
+
const typeVarScopeNode = ParseTreeUtils.getTypeVarScopeNode(curNode);
|
1053
|
+
if (!typeVarScopeNode) {
|
1054
|
+
break;
|
1055
|
+
}
|
1056
|
+
if (typeVarScopeNode.nodeType === 10 /* ParseNodeType.Class */) {
|
1057
|
+
const classType = (_c = this._evaluator.getTypeOfClass(typeVarScopeNode)) === null || _c === void 0 ? void 0 : _c.classType;
|
1058
|
+
if (classType === null || classType === void 0 ? void 0 : classType.details.typeParameters.some((param) => param.details.name === node.name.value)) {
|
1059
|
+
foundDuplicate = true;
|
1060
|
+
break;
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
else if (typeVarScopeNode.nodeType === 28 /* ParseNodeType.Function */) {
|
1064
|
+
const functionType = (_d = this._evaluator.getTypeOfFunction(typeVarScopeNode)) === null || _d === void 0 ? void 0 : _d.functionType;
|
1065
|
+
if (functionType === null || functionType === void 0 ? void 0 : functionType.details.typeParameters.some((param) => param.details.name === node.name.value)) {
|
1066
|
+
foundDuplicate = true;
|
1067
|
+
break;
|
1068
|
+
}
|
1069
|
+
}
|
1070
|
+
curNode = typeVarScopeNode.parent;
|
1071
|
+
}
|
1072
|
+
if (foundDuplicate) {
|
1073
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeVarUsedByOuterScope().format({ name: node.name.value }), node.name);
|
1074
|
+
}
|
1046
1075
|
return false;
|
1047
1076
|
}
|
1048
1077
|
visitTypeAlias(node) {
|
1049
1078
|
const scope = (0, scopeUtils_1.getScopeForNode)(node);
|
1050
1079
|
if (scope) {
|
1051
|
-
if (scope.type !==
|
1080
|
+
if (scope.type !== 3 /* ScopeType.Class */ && scope.type !== 4 /* ScopeType.Module */ && scope.type !== 5 /* ScopeType.Builtin */) {
|
1052
1081
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasStatementBadScope(), node.name);
|
1053
1082
|
}
|
1054
1083
|
}
|
@@ -2010,8 +2039,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2010
2039
|
// Report unaccessed type parameters.
|
2011
2040
|
const accessedSymbolSet = this._fileInfo.accessedSymbolSet;
|
2012
2041
|
for (const paramList of this._typeParameterLists) {
|
2042
|
+
const typeParamScope = AnalyzerNodeInfo.getScope(paramList);
|
2013
2043
|
for (const param of paramList.parameters) {
|
2014
|
-
const symbol =
|
2044
|
+
const symbol = typeParamScope === null || typeParamScope === void 0 ? void 0 : typeParamScope.symbolTable.get(param.name.value);
|
2015
2045
|
if (!symbol) {
|
2016
2046
|
// This can happen if the code is unreachable.
|
2017
2047
|
return;
|
@@ -2127,7 +2157,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2127
2157
|
// the type evaluator because we need to take into account whether
|
2128
2158
|
// the assignment is within an `__init__` method, so ignore class
|
2129
2159
|
// scopes here.
|
2130
|
-
if (scopeType !==
|
2160
|
+
if (scopeType !== 3 /* ScopeType.Class */) {
|
2131
2161
|
reportRedeclaration = true;
|
2132
2162
|
}
|
2133
2163
|
}
|
@@ -2856,7 +2886,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2856
2886
|
_isSymbolPrivate(nameValue, scopeType) {
|
2857
2887
|
// All variables within the scope of a function or a list
|
2858
2888
|
// comprehension are considered private.
|
2859
|
-
if (scopeType ===
|
2889
|
+
if (scopeType === 2 /* ScopeType.Function */ || scopeType === 1 /* ScopeType.ListComprehension */) {
|
2860
2890
|
return true;
|
2861
2891
|
}
|
2862
2892
|
// See if the symbol is private.
|
@@ -2865,7 +2895,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2865
2895
|
}
|
2866
2896
|
if (SymbolNameUtils.isProtectedName(nameValue)) {
|
2867
2897
|
// Protected names outside of a class scope are considered private.
|
2868
|
-
const isClassScope = scopeType ===
|
2898
|
+
const isClassScope = scopeType === 3 /* ScopeType.Class */;
|
2869
2899
|
return !isClassScope;
|
2870
2900
|
}
|
2871
2901
|
return false;
|
@@ -2959,6 +2989,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2959
2989
|
name: type.details.name,
|
2960
2990
|
});
|
2961
2991
|
}
|
2992
|
+
else if ((0, types_1.isClassInstance)(type) && overload.details.name === '__call__') {
|
2993
|
+
deprecatedMessage = overload.details.deprecatedMessage;
|
2994
|
+
errorMessage = localize_1.LocMessage.deprecatedFunction().format({
|
2995
|
+
name: node.value,
|
2996
|
+
});
|
2997
|
+
}
|
2962
2998
|
}
|
2963
2999
|
});
|
2964
3000
|
}
|
@@ -2970,15 +3006,16 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2970
3006
|
node.value === subtype.details.name) {
|
2971
3007
|
deprecatedMessage = subtype.details.deprecatedMessage;
|
2972
3008
|
errorMessage = localize_1.LocMessage.deprecatedClass().format({ name: subtype.details.name });
|
3009
|
+
return;
|
2973
3010
|
}
|
2974
|
-
|
2975
|
-
|
2976
|
-
getDeprecatedMessageForOverloadedCall(this._evaluator, subtype);
|
2977
|
-
}
|
3011
|
+
getDeprecatedMessageForOverloadedCall(this._evaluator, subtype);
|
3012
|
+
return;
|
2978
3013
|
}
|
2979
|
-
|
3014
|
+
if ((0, types_1.isFunction)(subtype)) {
|
2980
3015
|
if (subtype.details.deprecatedMessage !== undefined) {
|
2981
|
-
if (!subtype.details.name ||
|
3016
|
+
if (!subtype.details.name ||
|
3017
|
+
subtype.details.name === '__call__' ||
|
3018
|
+
node.value === subtype.details.name) {
|
2982
3019
|
deprecatedMessage = subtype.details.deprecatedMessage;
|
2983
3020
|
errorMessage = getDeprecatedMessageForFunction(subtype);
|
2984
3021
|
}
|
@@ -4742,7 +4779,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4742
4779
|
isClassVar = true;
|
4743
4780
|
}
|
4744
4781
|
}
|
4745
|
-
|
4782
|
+
// Allow TypedDict members to have the same name as class variables in the
|
4783
|
+
// base class because TypedDict members are not really instance members.
|
4784
|
+
const ignoreTypedDictOverride = types_1.ClassType.isTypedDictClass(childClassType) && !isClassVar;
|
4785
|
+
if (isBaseClassVar !== isClassVar && !ignoreTypedDictOverride) {
|
4746
4786
|
const unformattedMessage = overrideSymbol.isClassVar()
|
4747
4787
|
? localize_1.LocMessage.classVarOverridesInstanceVar()
|
4748
4788
|
: localize_1.LocMessage.instanceVarOverridesClassVar();
|
@@ -4932,7 +4972,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4932
4972
|
if (functionType.details.name === '__init__' && functionType.details.methodClass) {
|
4933
4973
|
const typeVars = (0, typeUtils_1.getTypeVarArgumentsRecursive)(paramInfo.type);
|
4934
4974
|
if (typeVars.some((typeVar) => { var _a; return typeVar.scopeId === ((_a = functionType.details.methodClass) === null || _a === void 0 ? void 0 : _a.details.typeVarScopeId); })) {
|
4935
|
-
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
4975
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.LocMessage.initMethodSelfParamTypeVar(), paramInfo.typeAnnotation);
|
4936
4976
|
}
|
4937
4977
|
}
|
4938
4978
|
// If this is a protocol class, the self and cls parameters can be bound
|