@zzzen/pyright-internal 1.2.0-dev.20240421 → 1.2.0-dev.20240505
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 +98 -45
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constructors.js +31 -13
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +1 -1
- package/dist/analyzer/dataClasses.js +23 -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/operations.js +3 -2
- package/dist/analyzer/operations.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/patternMatching.js +19 -13
- package/dist/analyzer/patternMatching.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 +28 -17
- 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/typeEvaluator.js +252 -207
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +5 -1
- package/dist/analyzer/typeGuards.js +35 -110
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.js +6 -8
- 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 +13 -0
- package/dist/analyzer/types.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/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 +1 -2
- package/dist/common/envVarUtils.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/uri/uri.d.ts +2 -0
- package/dist/common/uri/uri.js +3 -1
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/languageServerBase.d.ts +3 -2
- package/dist/languageServerBase.js +13 -35
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +5 -2
- 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/dynamicFeature.d.ts +18 -0
- package/dist/languageService/dynamicFeature.js +54 -0
- package/dist/languageService/dynamicFeature.js.map +1 -0
- package/dist/languageService/fileWatcherDynamicFeature.d.ts +12 -0
- package/dist/languageService/fileWatcherDynamicFeature.js +49 -0
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -0
- package/dist/languageService/referencesProvider.js +3 -2
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/localization/package.nls.cs.json +28 -26
- package/dist/localization/package.nls.de.json +28 -26
- package/dist/localization/package.nls.en-us.json +1 -1
- package/dist/localization/package.nls.es.json +27 -25
- package/dist/localization/package.nls.fr.json +28 -26
- package/dist/localization/package.nls.it.json +28 -26
- package/dist/localization/package.nls.ja.json +28 -26
- package/dist/localization/package.nls.ko.json +28 -26
- package/dist/localization/package.nls.pl.json +27 -25
- package/dist/localization/package.nls.pt-br.json +28 -26
- package/dist/localization/package.nls.qps-ploc.json +25 -23
- package/dist/localization/package.nls.ru.json +28 -26
- package/dist/localization/package.nls.tr.json +28 -26
- package/dist/localization/package.nls.zh-cn.json +28 -26
- package/dist/localization/package.nls.zh-tw.json +28 -26
- package/dist/parser/parseNodes.d.ts +2 -2
- package/dist/parser/tokenizer.js +7 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/tests/checker.test.js +8 -0
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/envVarUtils.test.js +20 -0
- package/dist/tests/envVarUtils.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/parser.test.js +7 -2
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +60 -480
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +0 -482
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +0 -604
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +5 -423
- 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/tests/typeEvaluator6.test.d.ts +1 -0
- package/dist/tests/typeEvaluator6.test.js +712 -0
- package/dist/tests/typeEvaluator6.test.js.map +1 -0
- package/dist/tests/typeEvaluator7.test.d.ts +1 -0
- package/dist/tests/typeEvaluator7.test.js +677 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -0
- package/dist/tests/typeEvaluator8.test.d.ts +1 -0
- package/dist/tests/typeEvaluator8.test.js +660 -0
- package/dist/tests/typeEvaluator8.test.js.map +1 -0
- 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
|
}
|
@@ -767,31 +767,37 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
767
767
|
if (baseType) {
|
768
768
|
(0, typeUtils_1.doForEachSubtype)(baseType, (subtype) => {
|
769
769
|
const tupleType = (0, typeUtils_1.getSpecializedTupleType)(subtype);
|
770
|
-
if ((0, types_1.isClassInstance)(subtype)
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.tupleIndexOutOfRange().format({
|
788
|
-
index: subscriptType.literalValue,
|
789
|
-
type: this._evaluator.printType(subtype),
|
790
|
-
}), node);
|
791
|
-
}
|
792
|
-
}
|
793
|
-
}
|
770
|
+
if (!(0, types_1.isClassInstance)(subtype) || !(tupleType === null || tupleType === void 0 ? void 0 : tupleType.tupleTypeArguments) || (0, typeUtils_1.isUnboundedTupleClass)(tupleType)) {
|
771
|
+
return;
|
772
|
+
}
|
773
|
+
const tupleLength = tupleType.tupleTypeArguments.length;
|
774
|
+
if (node.items.length !== 1 ||
|
775
|
+
node.trailingComma ||
|
776
|
+
node.items[0].argumentCategory !== 0 /* ArgumentCategory.Simple */ ||
|
777
|
+
node.items[0].name) {
|
778
|
+
return;
|
779
|
+
}
|
780
|
+
const subscriptType = this._evaluator.getType(node.items[0].valueExpression);
|
781
|
+
if (!subscriptType ||
|
782
|
+
!(0, types_1.isClassInstance)(subscriptType) ||
|
783
|
+
!types_1.ClassType.isBuiltIn(subscriptType, 'int') ||
|
784
|
+
!(0, typeUtils_1.isLiteralType)(subscriptType) ||
|
785
|
+
typeof subscriptType.literalValue !== 'number') {
|
786
|
+
return;
|
794
787
|
}
|
788
|
+
if ((subscriptType.literalValue < 0 || subscriptType.literalValue < tupleLength) &&
|
789
|
+
(subscriptType.literalValue >= 0 || subscriptType.literalValue + tupleLength >= 0)) {
|
790
|
+
return;
|
791
|
+
}
|
792
|
+
// This can be an expensive check, so we save it for the end once we
|
793
|
+
// are about to emit a diagnostic.
|
794
|
+
if (this._evaluator.isTypeSubsumedByOtherType(tupleType, baseType, /* allowAnyToSubsume */ false)) {
|
795
|
+
return;
|
796
|
+
}
|
797
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.tupleIndexOutOfRange().format({
|
798
|
+
index: subscriptType.literalValue,
|
799
|
+
type: this._evaluator.printType(subtype),
|
800
|
+
}), node);
|
795
801
|
});
|
796
802
|
}
|
797
803
|
return true;
|
@@ -1043,12 +1049,41 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1043
1049
|
return true;
|
1044
1050
|
}
|
1045
1051
|
visitTypeParameter(node) {
|
1052
|
+
var _a, _b, _c, _d;
|
1053
|
+
// Verify that there are no live type variables with the same
|
1054
|
+
// name in outer scopes.
|
1055
|
+
let curNode = (_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent;
|
1056
|
+
let foundDuplicate = false;
|
1057
|
+
while (curNode) {
|
1058
|
+
const typeVarScopeNode = ParseTreeUtils.getTypeVarScopeNode(curNode);
|
1059
|
+
if (!typeVarScopeNode) {
|
1060
|
+
break;
|
1061
|
+
}
|
1062
|
+
if (typeVarScopeNode.nodeType === 10 /* ParseNodeType.Class */) {
|
1063
|
+
const classType = (_c = this._evaluator.getTypeOfClass(typeVarScopeNode)) === null || _c === void 0 ? void 0 : _c.classType;
|
1064
|
+
if (classType === null || classType === void 0 ? void 0 : classType.details.typeParameters.some((param) => param.details.name === node.name.value)) {
|
1065
|
+
foundDuplicate = true;
|
1066
|
+
break;
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
else if (typeVarScopeNode.nodeType === 28 /* ParseNodeType.Function */) {
|
1070
|
+
const functionType = (_d = this._evaluator.getTypeOfFunction(typeVarScopeNode)) === null || _d === void 0 ? void 0 : _d.functionType;
|
1071
|
+
if (functionType === null || functionType === void 0 ? void 0 : functionType.details.typeParameters.some((param) => param.details.name === node.name.value)) {
|
1072
|
+
foundDuplicate = true;
|
1073
|
+
break;
|
1074
|
+
}
|
1075
|
+
}
|
1076
|
+
curNode = typeVarScopeNode.parent;
|
1077
|
+
}
|
1078
|
+
if (foundDuplicate) {
|
1079
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeVarUsedByOuterScope().format({ name: node.name.value }), node.name);
|
1080
|
+
}
|
1046
1081
|
return false;
|
1047
1082
|
}
|
1048
1083
|
visitTypeAlias(node) {
|
1049
1084
|
const scope = (0, scopeUtils_1.getScopeForNode)(node);
|
1050
1085
|
if (scope) {
|
1051
|
-
if (scope.type !==
|
1086
|
+
if (scope.type !== 3 /* ScopeType.Class */ && scope.type !== 4 /* ScopeType.Module */ && scope.type !== 5 /* ScopeType.Builtin */) {
|
1052
1087
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasStatementBadScope(), node.name);
|
1053
1088
|
}
|
1054
1089
|
}
|
@@ -2010,8 +2045,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2010
2045
|
// Report unaccessed type parameters.
|
2011
2046
|
const accessedSymbolSet = this._fileInfo.accessedSymbolSet;
|
2012
2047
|
for (const paramList of this._typeParameterLists) {
|
2048
|
+
const typeParamScope = AnalyzerNodeInfo.getScope(paramList);
|
2013
2049
|
for (const param of paramList.parameters) {
|
2014
|
-
const symbol =
|
2050
|
+
const symbol = typeParamScope === null || typeParamScope === void 0 ? void 0 : typeParamScope.symbolTable.get(param.name.value);
|
2015
2051
|
if (!symbol) {
|
2016
2052
|
// This can happen if the code is unreachable.
|
2017
2053
|
return;
|
@@ -2123,11 +2159,18 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2123
2159
|
if (decl.type === 1 /* DeclarationType.Variable */) {
|
2124
2160
|
if (decl.inferredTypeSource) {
|
2125
2161
|
if (sawAssignment) {
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2162
|
+
let exemptAssignment = false;
|
2163
|
+
if (scopeType === 3 /* ScopeType.Class */) {
|
2164
|
+
// We check for assignment of Final instance and class variables
|
2165
|
+
// in the type evaluator because we need to take into account whether
|
2166
|
+
// the assignment is within an `__init__` method, so ignore class
|
2167
|
+
// scopes here.
|
2168
|
+
const classOrFunc = ParseTreeUtils.getEnclosingClassOrFunction(decl.node);
|
2169
|
+
if ((classOrFunc === null || classOrFunc === void 0 ? void 0 : classOrFunc.nodeType) === 28 /* ParseNodeType.Function */) {
|
2170
|
+
exemptAssignment = true;
|
2171
|
+
}
|
2172
|
+
}
|
2173
|
+
if (!exemptAssignment) {
|
2131
2174
|
reportRedeclaration = true;
|
2132
2175
|
}
|
2133
2176
|
}
|
@@ -2856,7 +2899,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2856
2899
|
_isSymbolPrivate(nameValue, scopeType) {
|
2857
2900
|
// All variables within the scope of a function or a list
|
2858
2901
|
// comprehension are considered private.
|
2859
|
-
if (scopeType ===
|
2902
|
+
if (scopeType === 2 /* ScopeType.Function */ || scopeType === 1 /* ScopeType.ListComprehension */) {
|
2860
2903
|
return true;
|
2861
2904
|
}
|
2862
2905
|
// See if the symbol is private.
|
@@ -2865,7 +2908,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2865
2908
|
}
|
2866
2909
|
if (SymbolNameUtils.isProtectedName(nameValue)) {
|
2867
2910
|
// Protected names outside of a class scope are considered private.
|
2868
|
-
const isClassScope = scopeType ===
|
2911
|
+
const isClassScope = scopeType === 3 /* ScopeType.Class */;
|
2869
2912
|
return !isClassScope;
|
2870
2913
|
}
|
2871
2914
|
return false;
|
@@ -2959,6 +3002,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2959
3002
|
name: type.details.name,
|
2960
3003
|
});
|
2961
3004
|
}
|
3005
|
+
else if ((0, types_1.isClassInstance)(type) && overload.details.name === '__call__') {
|
3006
|
+
deprecatedMessage = overload.details.deprecatedMessage;
|
3007
|
+
errorMessage = localize_1.LocMessage.deprecatedFunction().format({
|
3008
|
+
name: node.value,
|
3009
|
+
});
|
3010
|
+
}
|
2962
3011
|
}
|
2963
3012
|
});
|
2964
3013
|
}
|
@@ -2970,15 +3019,16 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2970
3019
|
node.value === subtype.details.name) {
|
2971
3020
|
deprecatedMessage = subtype.details.deprecatedMessage;
|
2972
3021
|
errorMessage = localize_1.LocMessage.deprecatedClass().format({ name: subtype.details.name });
|
3022
|
+
return;
|
2973
3023
|
}
|
2974
|
-
|
2975
|
-
|
2976
|
-
getDeprecatedMessageForOverloadedCall(this._evaluator, subtype);
|
2977
|
-
}
|
3024
|
+
getDeprecatedMessageForOverloadedCall(this._evaluator, subtype);
|
3025
|
+
return;
|
2978
3026
|
}
|
2979
|
-
|
3027
|
+
if ((0, types_1.isFunction)(subtype)) {
|
2980
3028
|
if (subtype.details.deprecatedMessage !== undefined) {
|
2981
|
-
if (!subtype.details.name ||
|
3029
|
+
if (!subtype.details.name ||
|
3030
|
+
subtype.details.name === '__call__' ||
|
3031
|
+
node.value === subtype.details.name) {
|
2982
3032
|
deprecatedMessage = subtype.details.deprecatedMessage;
|
2983
3033
|
errorMessage = getDeprecatedMessageForFunction(subtype);
|
2984
3034
|
}
|
@@ -4742,7 +4792,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4742
4792
|
isClassVar = true;
|
4743
4793
|
}
|
4744
4794
|
}
|
4745
|
-
|
4795
|
+
// Allow TypedDict members to have the same name as class variables in the
|
4796
|
+
// base class because TypedDict members are not really instance members.
|
4797
|
+
const ignoreTypedDictOverride = types_1.ClassType.isTypedDictClass(childClassType) && !isClassVar;
|
4798
|
+
if (isBaseClassVar !== isClassVar && !ignoreTypedDictOverride) {
|
4746
4799
|
const unformattedMessage = overrideSymbol.isClassVar()
|
4747
4800
|
? localize_1.LocMessage.classVarOverridesInstanceVar()
|
4748
4801
|
: localize_1.LocMessage.instanceVarOverridesClassVar();
|
@@ -4932,7 +4985,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4932
4985
|
if (functionType.details.name === '__init__' && functionType.details.methodClass) {
|
4933
4986
|
const typeVars = (0, typeUtils_1.getTypeVarArgumentsRecursive)(paramInfo.type);
|
4934
4987
|
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.
|
4988
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.LocMessage.initMethodSelfParamTypeVar(), paramInfo.typeAnnotation);
|
4936
4989
|
}
|
4937
4990
|
}
|
4938
4991
|
// If this is a protocol class, the self and cls parameters can be bound
|