@zzzen/pyright-internal 1.2.0-dev.20240616 → 1.2.0-dev.20240630
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/cacheManager.js +3 -0
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +3 -0
- package/dist/analyzer/checker.js +242 -153
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +1 -1
- package/dist/analyzer/codeFlowEngine.js +7 -12
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constructors.js +28 -3
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +2 -1
- package/dist/analyzer/dataClasses.js +5 -2
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +4 -8
- package/dist/analyzer/importResolver.js +87 -85
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +18 -2
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +22 -5
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/service.js +1 -1
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +202 -215
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +0 -1
- package/dist/analyzer/typeGuards.js +42 -14
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.js +19 -9
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.js +11 -7
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.js +3 -1
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.js +1 -1
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +2 -2
- package/dist/common/collectionUtils.d.ts +2 -2
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/core.d.ts +8 -3
- package/dist/common/core.js.map +1 -1
- package/dist/common/diagnostic.d.ts +1 -0
- package/dist/common/diagnostic.js +5 -0
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/docStringService.d.ts +2 -1
- package/dist/common/docStringService.js.map +1 -1
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/textRangeCollection.d.ts +1 -1
- package/dist/common/textRangeCollection.js +14 -14
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/languageServerBase.js +20 -16
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +7 -4
- package/dist/languageService/autoImporter.js +15 -12
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +1 -0
- package/dist/languageService/completionProvider.js +22 -17
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +1 -1
- package/dist/languageService/hoverProvider.js +11 -7
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +19 -2
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +2 -1
- package/dist/localization/localize.js +3 -2
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +4 -1
- 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 +4 -1
- 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 +3 -1
- package/dist/parser/parseNodes.js +3 -1
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js +14 -6
- package/dist/parser/parser.js.map +1 -1
- package/dist/tests/checker.test.js +2 -2
- package/dist/tests/completions.test.js +80 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +5 -5
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -1
- package/dist/tests/languageServer.test.js +39 -4
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/lsp/languageServer.js +19 -3
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +89 -0
- package/dist/tests/parseTreeUtils.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 +5 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +4 -0
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +1 -1
- package/dist/tests/typeEvaluator8.test.js +1 -1
- package/package.json +4 -4
@@ -88,6 +88,9 @@ class CacheManager {
|
|
88
88
|
}
|
89
89
|
// Returns a ratio of used bytes to total bytes.
|
90
90
|
getUsedHeapRatio(console) {
|
91
|
+
if (this._pausedCount > 0) {
|
92
|
+
return -1;
|
93
|
+
}
|
91
94
|
const heapStats = (0, memUtils_1.getHeapStatistics)();
|
92
95
|
let usage = this._getTotalHeapUsage(heapStats);
|
93
96
|
if (console && Date.now() - this._lastHeapStats > 1000) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cacheManager.js","sourceRoot":"","sources":["../../../../../src/analyzer/cacheManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAMH,2CAAuC;AACvC,iDAAuD;AAWvD,MAAa,YAAY;IAOrB,YAA6B,cAAsB,CAAC;QAAvB,gBAAW,GAAX,WAAW,CAAY;QAN5C,iBAAY,GAAG,CAAC,CAAC;QACR,iBAAY,GAAiB,EAAE,CAAC;QAEzC,yBAAoB,GAAG,CAAC,CAAC;QACzB,mBAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEmB,CAAC;IACxD,kBAAkB,CAAC,QAAoB;QACnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,MAAc;QACnC,6DAA6D;QAC7D,8CAA8C;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC5C,IAAI,MAAM,EAAE;YACR,uEAAuE;YACvE,8BAA8B;YAC9B,MAAM,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC3G,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;gBACnB,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAED,8BAA8B,CAAC,GAAoB;QAC/C,IAAI,GAAG,CAAC,WAAW,KAAK,kBAAkB,EAAE;YACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;YACxC,MAAM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AS,CAAC;SACpB;IACL,CAAC;IAEO,kBAAkB,CAAC,SAAmB;QAC1C,sEAAsE;QACtE,6CAA6C;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC5C,IAAI,MAAM,EAAE;YACR,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;YACtC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAC,cAAc,CAAC;YAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;SAC1C;QAED,OAAO,SAAS,CAAC,cAAc,CAAC;IACpC,CAAC;CACJ;AArJD,oCAqJC;AAED,WAAiB,YAAY;IACzB,SAAgB,EAAE,CAAC,GAAQ;QACvB,OAAO,CACH,GAAG,CAAC,kBAAkB,KAAK,SAAS;YACpC,GAAG,CAAC,oBAAoB,KAAK,SAAS;YACtC,GAAG,CAAC,aAAa,KAAK,SAAS;YAC/B,GAAG,CAAC,aAAa,KAAK,SAAS;YAC/B,GAAG,CAAC,UAAU,KAAK,SAAS;YAC5B,GAAG,CAAC,gBAAgB,KAAK,SAAS,CACrC,CAAC;IACN,CAAC;IATe,eAAE,KASjB,CAAA;AACL,CAAC,EAXgB,YAAY,4BAAZ,YAAY,QAW5B"}
|
@@ -133,6 +133,8 @@ export declare class Checker extends ParseTreeWalker {
|
|
133
133
|
private _validateMultipleInheritanceBaseClasses;
|
134
134
|
private _validateMultipleInheritanceCompatibility;
|
135
135
|
private _validateMultipleInheritanceOverride;
|
136
|
+
private _addMultipleInheritanceRelatedInfo;
|
137
|
+
private _validateMultipleInheritancePropertyOverride;
|
136
138
|
private _validateOverloadDecoratorConsistency;
|
137
139
|
private _validateTypedDictOverrides;
|
138
140
|
private _validateBaseClassOverrides;
|
@@ -140,6 +142,7 @@ export declare class Checker extends ParseTreeWalker {
|
|
140
142
|
private _isMethodExemptFromLsp;
|
141
143
|
private _validateOverrideDecoratorNotPresent;
|
142
144
|
private _validateBaseClassOverride;
|
145
|
+
private _validatePropertyOverride;
|
143
146
|
private _validateMethod;
|
144
147
|
private _validateSuperCallForMethod;
|
145
148
|
private _validateClsSelfParameterType;
|
package/dist/analyzer/checker.js
CHANGED
@@ -51,6 +51,7 @@ const parseNodes_1 = require("../parser/parseNodes");
|
|
51
51
|
const stringTokenUtils_1 = require("../parser/stringTokenUtils");
|
52
52
|
const AnalyzerNodeInfo = __importStar(require("./analyzerNodeInfo"));
|
53
53
|
const constructors_1 = require("./constructors");
|
54
|
+
const dataClasses_1 = require("./dataClasses");
|
54
55
|
const declaration_1 = require("./declaration");
|
55
56
|
const declarationUtils_1 = require("./declarationUtils");
|
56
57
|
const deprecatedSymbols_1 = require("./deprecatedSymbols");
|
@@ -574,7 +575,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
574
575
|
else {
|
575
576
|
let diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
576
577
|
let returnTypeMatches = false;
|
577
|
-
if (this._evaluator.assignType(declaredReturnType, returnType, diagAddendum,
|
578
|
+
if (this._evaluator.assignType(declaredReturnType, returnType, diagAddendum,
|
579
|
+
/* destTypeVarContext */ undefined,
|
578
580
|
/* srcTypeVarContext */ undefined, 128 /* AssignTypeFlags.AllowBoolTypeGuard */)) {
|
579
581
|
returnTypeMatches = true;
|
580
582
|
}
|
@@ -2083,82 +2085,91 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2083
2085
|
}
|
2084
2086
|
_reportInvalidOverload(name, symbol) {
|
2085
2087
|
const typedDecls = symbol.getTypedDeclarations();
|
2086
|
-
if (typedDecls.length
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2088
|
+
if (typedDecls.length === 0) {
|
2089
|
+
return;
|
2090
|
+
}
|
2091
|
+
const primaryDecl = typedDecls[0];
|
2092
|
+
if (primaryDecl.type !== 5 /* DeclarationType.Function */) {
|
2093
|
+
return;
|
2094
|
+
}
|
2095
|
+
const type = this._evaluator.getEffectiveTypeOfSymbol(symbol);
|
2096
|
+
const overloadedFunctions = (0, types_1.isOverloadedFunction)(type)
|
2097
|
+
? types_1.OverloadedFunctionType.getOverloads(type)
|
2098
|
+
: (0, types_1.isFunction)(type) && types_1.FunctionType.isOverloaded(type)
|
2099
|
+
? [type]
|
2100
|
+
: [];
|
2101
|
+
// If the implementation has no name, it was synthesized probably by a
|
2102
|
+
// decorator that used a callable with a ParamSpec that captured the
|
2103
|
+
// overloaded signature. We'll exempt it from this check.
|
2104
|
+
if ((0, types_1.isOverloadedFunction)(type)) {
|
2105
|
+
const overloads = types_1.OverloadedFunctionType.getOverloads(type);
|
2106
|
+
if (overloads.length > 0 && overloads[0].details.name === '') {
|
2107
|
+
return;
|
2108
|
+
}
|
2109
|
+
}
|
2110
|
+
else if ((0, types_1.isFunction)(type)) {
|
2111
|
+
if (type.details.name === '') {
|
2112
|
+
return;
|
2113
|
+
}
|
2114
|
+
}
|
2115
|
+
if (overloadedFunctions.length === 1) {
|
2116
|
+
// There should never be a single overload.
|
2117
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.singleOverload().format({ name }), primaryDecl.node.name);
|
2118
|
+
}
|
2119
|
+
// If the file is not a stub and this is the first overload,
|
2120
|
+
// verify that there is an implementation.
|
2121
|
+
if (this._fileInfo.isStubFile || overloadedFunctions.length === 0) {
|
2122
|
+
return;
|
2123
|
+
}
|
2124
|
+
let implementationFunction;
|
2125
|
+
if ((0, types_1.isOverloadedFunction)(type)) {
|
2126
|
+
implementationFunction = types_1.OverloadedFunctionType.getImplementation(type);
|
2127
|
+
}
|
2128
|
+
else if ((0, types_1.isFunction)(type) && !types_1.FunctionType.isOverloaded(type)) {
|
2129
|
+
implementationFunction = type;
|
2130
|
+
}
|
2131
|
+
if (!implementationFunction) {
|
2132
|
+
const containingClassNode = ParseTreeUtils.getEnclosingClassOrFunction(primaryDecl.node);
|
2133
|
+
if (containingClassNode && containingClassNode.nodeType === 10 /* ParseNodeType.Class */) {
|
2134
|
+
const classType = this._evaluator.getTypeOfClass(containingClassNode);
|
2135
|
+
if (classType) {
|
2136
|
+
if (types_1.ClassType.isProtocolClass(classType.classType)) {
|
2137
|
+
return;
|
2116
2138
|
}
|
2117
|
-
if (
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
if (classType) {
|
2122
|
-
if (types_1.ClassType.isProtocolClass(classType.classType)) {
|
2123
|
-
exemptMissingImplementation = true;
|
2124
|
-
}
|
2125
|
-
else if (types_1.ClassType.supportsAbstractMethods(classType.classType)) {
|
2126
|
-
if ((0, types_1.isOverloadedFunction)(type) &&
|
2127
|
-
types_1.OverloadedFunctionType.getOverloads(type).every((overload) => types_1.FunctionType.isAbstractMethod(overload))) {
|
2128
|
-
exemptMissingImplementation = true;
|
2129
|
-
}
|
2130
|
-
}
|
2131
|
-
}
|
2132
|
-
}
|
2133
|
-
// If this is a method within a protocol class, don't require that
|
2134
|
-
// there is an implementation.
|
2135
|
-
if (!exemptMissingImplementation) {
|
2136
|
-
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportNoOverloadImplementation, localize_1.LocMessage.overloadWithoutImplementation().format({
|
2137
|
-
name: primaryDecl.node.name.value,
|
2138
|
-
}), primaryDecl.node.name);
|
2139
|
+
if (types_1.ClassType.supportsAbstractMethods(classType.classType)) {
|
2140
|
+
if ((0, types_1.isOverloadedFunction)(type) &&
|
2141
|
+
types_1.OverloadedFunctionType.getOverloads(type).every((overload) => types_1.FunctionType.isAbstractMethod(overload))) {
|
2142
|
+
return;
|
2139
2143
|
}
|
2140
2144
|
}
|
2141
|
-
else if ((0, types_1.isOverloadedFunction)(type)) {
|
2142
|
-
// Verify that all overload signatures are assignable to implementation signature.
|
2143
|
-
types_1.OverloadedFunctionType.getOverloads(type).forEach((overload, index) => {
|
2144
|
-
var _a, _b, _c, _d;
|
2145
|
-
const diag = new diagnostic_1.DiagnosticAddendum();
|
2146
|
-
if (!this._isLegalOverloadImplementation(overload, implementationFunction, diag)) {
|
2147
|
-
if (implementationFunction.details.declaration) {
|
2148
|
-
const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.overloadImplementationMismatch().format({
|
2149
|
-
name,
|
2150
|
-
index: index + 1,
|
2151
|
-
}) + diag.getString(), implementationFunction.details.declaration.node.name);
|
2152
|
-
if (diagnostic && overload.details.declaration) {
|
2153
|
-
diagnostic.addRelatedInfo(localize_1.LocAddendum.overloadSignature(), (_b = (_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.uri) !== null && _b !== void 0 ? _b : primaryDecl.uri, (_d = (_c = overload.details.declaration) === null || _c === void 0 ? void 0 : _c.range) !== null && _d !== void 0 ? _d : primaryDecl.range);
|
2154
|
-
}
|
2155
|
-
}
|
2156
|
-
}
|
2157
|
-
});
|
2158
|
-
}
|
2159
2145
|
}
|
2160
2146
|
}
|
2147
|
+
// If this is a method within a protocol class, don't require that
|
2148
|
+
// there is an implementation.
|
2149
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportNoOverloadImplementation, localize_1.LocMessage.overloadWithoutImplementation().format({
|
2150
|
+
name: primaryDecl.node.name.value,
|
2151
|
+
}), primaryDecl.node.name);
|
2152
|
+
return;
|
2153
|
+
}
|
2154
|
+
if (!(0, types_1.isOverloadedFunction)(type)) {
|
2155
|
+
return;
|
2161
2156
|
}
|
2157
|
+
// Verify that all overload signatures are assignable to implementation signature.
|
2158
|
+
types_1.OverloadedFunctionType.getOverloads(type).forEach((overload, index) => {
|
2159
|
+
var _a, _b, _c, _d;
|
2160
|
+
const diag = new diagnostic_1.DiagnosticAddendum();
|
2161
|
+
if (!this._isLegalOverloadImplementation(overload, implementationFunction, diag)) {
|
2162
|
+
if (implementationFunction.details.declaration) {
|
2163
|
+
const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.overloadImplementationMismatch().format({
|
2164
|
+
name,
|
2165
|
+
index: index + 1,
|
2166
|
+
}) + diag.getString(), implementationFunction.details.declaration.node.name);
|
2167
|
+
if (diagnostic && overload.details.declaration) {
|
2168
|
+
diagnostic.addRelatedInfo(localize_1.LocAddendum.overloadSignature(), (_b = (_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.uri) !== null && _b !== void 0 ? _b : primaryDecl.uri, (_d = (_c = overload.details.declaration) === null || _c === void 0 ? void 0 : _c.range) !== null && _d !== void 0 ? _d : primaryDecl.range);
|
2169
|
+
}
|
2170
|
+
}
|
2171
|
+
}
|
2172
|
+
});
|
2162
2173
|
}
|
2163
2174
|
_reportMultipleFinalDeclarations(name, symbol, scopeType) {
|
2164
2175
|
if (!this._evaluator.isFinalVariable(symbol)) {
|
@@ -3758,6 +3769,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3758
3769
|
if (types_1.ClassType.isFinal(classType)) {
|
3759
3770
|
(0, typeUtils_1.getProtocolSymbolsRecursive)(classType, abstractSymbols, 64 /* ClassTypeFlags.SupportsAbstractMethods */);
|
3760
3771
|
}
|
3772
|
+
// If this is a dataclass, get all of the entries so we can tell which
|
3773
|
+
// ones are initialized by the synthesized __init__ method.
|
3774
|
+
const dataClassEntries = [];
|
3775
|
+
if (types_1.ClassType.isDataClass(classType)) {
|
3776
|
+
(0, dataClasses_1.addInheritedDataClassEntries)(classType, dataClassEntries);
|
3777
|
+
}
|
3761
3778
|
types_1.ClassType.getSymbolTable(classType).forEach((localSymbol, name) => {
|
3762
3779
|
abstractSymbols.delete(name);
|
3763
3780
|
// This applies only to instance members.
|
@@ -3783,10 +3800,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3783
3800
|
((_c = decl.node.parent.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 3 /* ParseNodeType.Assignment */) {
|
3784
3801
|
return true;
|
3785
3802
|
}
|
3786
|
-
// If this is part of a dataclass
|
3787
|
-
// exempt it because the class variable will be transformed
|
3788
|
-
// variable in this case.
|
3789
|
-
if (types_1.ClassType.isDataClass(classType)) {
|
3803
|
+
// If this is part of a dataclass, a class handled by a dataclass_transform,
|
3804
|
+
// or a NamedTuple, exempt it because the class variable will be transformed
|
3805
|
+
// into an instance variable in this case.
|
3806
|
+
if (types_1.ClassType.isDataClass(classType) || types_1.ClassType.isReadOnlyInstanceVariables(classType)) {
|
3790
3807
|
return true;
|
3791
3808
|
}
|
3792
3809
|
// If this is part of a TypedDict, exempt it because the class variables
|
@@ -3819,18 +3836,27 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3819
3836
|
if (decls.length === 0 || !(0, types_1.isClass)(member.classType)) {
|
3820
3837
|
return;
|
3821
3838
|
}
|
3822
|
-
if (decls[0].type
|
3823
|
-
|
3824
|
-
|
3825
|
-
|
3826
|
-
|
3827
|
-
|
3828
|
-
|
3829
|
-
|
3830
|
-
|
3831
|
-
|
3839
|
+
if (decls[0].type !== 1 /* DeclarationType.Variable */) {
|
3840
|
+
return;
|
3841
|
+
}
|
3842
|
+
// Dataclass fields are typically exempted from this check because
|
3843
|
+
// they have synthesized __init__ methods that initialize these variables.
|
3844
|
+
const dcEntry = dataClassEntries === null || dataClassEntries === void 0 ? void 0 : dataClassEntries.find((entry) => entry.name === name);
|
3845
|
+
if (dcEntry) {
|
3846
|
+
if (dcEntry.includeInInit) {
|
3847
|
+
return;
|
3848
|
+
}
|
3849
|
+
}
|
3850
|
+
else {
|
3851
|
+
// Do one or more declarations involve assignments?
|
3852
|
+
if (decls.some((decl) => decl.type === 1 /* DeclarationType.Variable */ && !!decl.inferredTypeSource)) {
|
3853
|
+
return;
|
3832
3854
|
}
|
3833
3855
|
}
|
3856
|
+
diagAddendum.addMessage(localize_1.LocAddendum.uninitializedAbstractVariable().format({
|
3857
|
+
name,
|
3858
|
+
classType: member.classType.details.name,
|
3859
|
+
}));
|
3834
3860
|
});
|
3835
3861
|
if (!diagAddendum.isEmpty()) {
|
3836
3862
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUninitializedInstanceVariable, localize_1.LocMessage.uninitializedAbstractVariables().format({ classType: classType.details.name }) +
|
@@ -4216,7 +4242,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4216
4242
|
}
|
4217
4243
|
}
|
4218
4244
|
else {
|
4219
|
-
|
4245
|
+
this._validateMultipleInheritancePropertyOverride(overriddenClassAndSymbol.classType, childClassType, overriddenType, overrideType, overrideSymbol, memberName, errorNode);
|
4220
4246
|
}
|
4221
4247
|
}
|
4222
4248
|
else {
|
@@ -4283,15 +4309,76 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4283
4309
|
}
|
4284
4310
|
}
|
4285
4311
|
if (diag && overrideDecl && overriddenDecl) {
|
4286
|
-
|
4287
|
-
|
4288
|
-
|
4289
|
-
|
4290
|
-
|
4291
|
-
|
4292
|
-
|
4293
|
-
|
4294
|
-
|
4312
|
+
this._addMultipleInheritanceRelatedInfo(diag, overriddenClassAndSymbol.classType, overriddenType, overriddenDecl, overrideClassAndSymbol.classType, overrideType, overrideDecl);
|
4313
|
+
}
|
4314
|
+
}
|
4315
|
+
_addMultipleInheritanceRelatedInfo(diag, overriddenClass, overriddenType, overriddenDecl, overrideClass, overrideType, overrideDecl) {
|
4316
|
+
diag.addRelatedInfo(localize_1.LocAddendum.baseClassOverriddenType().format({
|
4317
|
+
baseClass: this._evaluator.printType((0, typeUtils_1.convertToInstance)(overriddenClass)),
|
4318
|
+
type: this._evaluator.printType(overriddenType),
|
4319
|
+
}), overriddenDecl.uri, overriddenDecl.range);
|
4320
|
+
diag.addRelatedInfo(localize_1.LocAddendum.baseClassOverridesType().format({
|
4321
|
+
baseClass: this._evaluator.printType((0, typeUtils_1.convertToInstance)(overrideClass)),
|
4322
|
+
type: this._evaluator.printType(overrideType),
|
4323
|
+
}), overrideDecl.uri, overrideDecl.range);
|
4324
|
+
}
|
4325
|
+
_validateMultipleInheritancePropertyOverride(overriddenClassType, overrideClassType, overriddenSymbolType, overrideSymbolType, overrideSymbol, memberName, errorNode) {
|
4326
|
+
const propMethodInfo = [
|
4327
|
+
['fget', (c) => { var _a; return (_a = c.fgetInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4328
|
+
['fset', (c) => { var _a; return (_a = c.fsetInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4329
|
+
['fdel', (c) => { var _a; return (_a = c.fdelInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4330
|
+
];
|
4331
|
+
propMethodInfo.forEach((info) => {
|
4332
|
+
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4333
|
+
const [methodName, methodAccessor] = info;
|
4334
|
+
const baseClassPropMethod = methodAccessor(overriddenSymbolType);
|
4335
|
+
const subclassPropMethod = methodAccessor(overrideSymbolType);
|
4336
|
+
// Is the method present on the base class but missing in the subclass?
|
4337
|
+
if (baseClassPropMethod) {
|
4338
|
+
const baseClassMethodType = (0, typeUtils_1.partiallySpecializeType)(baseClassPropMethod, overriddenClassType);
|
4339
|
+
if ((0, types_1.isFunction)(baseClassMethodType)) {
|
4340
|
+
if (!subclassPropMethod) {
|
4341
|
+
// The method is missing.
|
4342
|
+
diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodMissing().format({
|
4343
|
+
name: methodName,
|
4344
|
+
}));
|
4345
|
+
const decls = overrideSymbol.getDeclarations();
|
4346
|
+
if (decls.length > 0) {
|
4347
|
+
const lastDecl = decls[decls.length - 1];
|
4348
|
+
const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
|
4349
|
+
name: memberName,
|
4350
|
+
className: overriddenClassType.details.name,
|
4351
|
+
}) + diagAddendum.getString(), errorNode);
|
4352
|
+
const origDecl = baseClassMethodType.details.declaration;
|
4353
|
+
if (diag && origDecl) {
|
4354
|
+
this._addMultipleInheritanceRelatedInfo(diag, overriddenClassType, overriddenSymbolType, origDecl, overrideClassType, overrideSymbolType, lastDecl);
|
4355
|
+
}
|
4356
|
+
}
|
4357
|
+
}
|
4358
|
+
else {
|
4359
|
+
const subclassMethodType = (0, typeUtils_1.partiallySpecializeType)(subclassPropMethod, overrideClassType);
|
4360
|
+
if ((0, types_1.isFunction)(subclassMethodType)) {
|
4361
|
+
if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, overrideClassType, diagAddendum.createAddendum())) {
|
4362
|
+
diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodIncompatible().format({
|
4363
|
+
name: methodName,
|
4364
|
+
}));
|
4365
|
+
const decl = subclassMethodType.details.declaration;
|
4366
|
+
if (decl && decl.type === 5 /* DeclarationType.Function */) {
|
4367
|
+
const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
|
4368
|
+
name: memberName,
|
4369
|
+
className: overriddenClassType.details.name,
|
4370
|
+
}) + diagAddendum.getString(), errorNode);
|
4371
|
+
const origDecl = baseClassMethodType.details.declaration;
|
4372
|
+
if (diag && origDecl) {
|
4373
|
+
this._addMultipleInheritanceRelatedInfo(diag, overriddenClassType, overriddenSymbolType, origDecl, overrideClassType, overrideSymbolType, decl);
|
4374
|
+
}
|
4375
|
+
}
|
4376
|
+
}
|
4377
|
+
}
|
4378
|
+
}
|
4379
|
+
}
|
4380
|
+
}
|
4381
|
+
});
|
4295
4382
|
}
|
4296
4383
|
// Validates that any overloaded methods are consistent in how they
|
4297
4384
|
// are decorated. For example, if the first overload is not marked @final
|
@@ -4653,64 +4740,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4653
4740
|
}
|
4654
4741
|
}
|
4655
4742
|
else {
|
4656
|
-
|
4657
|
-
const propMethodInfo = [
|
4658
|
-
['fget', (c) => { var _a; return (_a = c.fgetInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4659
|
-
['fset', (c) => { var _a; return (_a = c.fsetInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4660
|
-
['fdel', (c) => { var _a; return (_a = c.fdelInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4661
|
-
];
|
4662
|
-
propMethodInfo.forEach((info) => {
|
4663
|
-
var _a;
|
4664
|
-
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4665
|
-
const [methodName, methodAccessor] = info;
|
4666
|
-
const baseClassPropMethod = methodAccessor(baseType);
|
4667
|
-
const subclassPropMethod = methodAccessor(overrideType);
|
4668
|
-
// Is the method present on the base class but missing in the subclass?
|
4669
|
-
if (baseClassPropMethod) {
|
4670
|
-
const baseClassMethodType = (0, typeUtils_1.partiallySpecializeType)(baseClassPropMethod, baseClassType);
|
4671
|
-
if ((0, types_1.isFunction)(baseClassMethodType)) {
|
4672
|
-
if (!subclassPropMethod) {
|
4673
|
-
// The method is missing.
|
4674
|
-
diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodMissing().format({
|
4675
|
-
name: methodName,
|
4676
|
-
}));
|
4677
|
-
const decls = overrideSymbol.getDeclarations();
|
4678
|
-
if (decls.length > 0) {
|
4679
|
-
const lastDecl = decls[decls.length - 1];
|
4680
|
-
const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
|
4681
|
-
name: memberName,
|
4682
|
-
className: baseClassType.details.name,
|
4683
|
-
}) + diagAddendum.getString(), (_a = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _a !== void 0 ? _a : lastDecl.node);
|
4684
|
-
const origDecl = baseClassMethodType.details.declaration;
|
4685
|
-
if (diag && origDecl) {
|
4686
|
-
diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
|
4687
|
-
}
|
4688
|
-
}
|
4689
|
-
}
|
4690
|
-
else {
|
4691
|
-
const subclassMethodType = (0, typeUtils_1.partiallySpecializeType)(subclassPropMethod, childClassType);
|
4692
|
-
if ((0, types_1.isFunction)(subclassMethodType)) {
|
4693
|
-
if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, childClassType, diagAddendum.createAddendum())) {
|
4694
|
-
diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodIncompatible().format({
|
4695
|
-
name: methodName,
|
4696
|
-
}));
|
4697
|
-
const decl = subclassMethodType.details.declaration;
|
4698
|
-
if (decl && decl.type === 5 /* DeclarationType.Function */) {
|
4699
|
-
const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
|
4700
|
-
name: memberName,
|
4701
|
-
className: baseClassType.details.name,
|
4702
|
-
}) + diagAddendum.getString(), decl.node.name);
|
4703
|
-
const origDecl = baseClassMethodType.details.declaration;
|
4704
|
-
if (diag && origDecl) {
|
4705
|
-
diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
|
4706
|
-
}
|
4707
|
-
}
|
4708
|
-
}
|
4709
|
-
}
|
4710
|
-
}
|
4711
|
-
}
|
4712
|
-
}
|
4713
|
-
});
|
4743
|
+
this._validatePropertyOverride(baseClass, childClassType, baseType, overrideType, overrideSymbol, memberName);
|
4714
4744
|
}
|
4715
4745
|
}
|
4716
4746
|
else {
|
@@ -4851,6 +4881,65 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4851
4881
|
}
|
4852
4882
|
}
|
4853
4883
|
}
|
4884
|
+
_validatePropertyOverride(baseClassType, childClassType, baseType, childType, overrideSymbol, memberName) {
|
4885
|
+
const propMethodInfo = [
|
4886
|
+
['fget', (c) => { var _a; return (_a = c.fgetInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4887
|
+
['fset', (c) => { var _a; return (_a = c.fsetInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4888
|
+
['fdel', (c) => { var _a; return (_a = c.fdelInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4889
|
+
];
|
4890
|
+
propMethodInfo.forEach((info) => {
|
4891
|
+
var _a;
|
4892
|
+
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4893
|
+
const [methodName, methodAccessor] = info;
|
4894
|
+
const baseClassPropMethod = methodAccessor(baseType);
|
4895
|
+
const subclassPropMethod = methodAccessor(childType);
|
4896
|
+
// Is the method present on the base class but missing in the subclass?
|
4897
|
+
if (baseClassPropMethod) {
|
4898
|
+
const baseClassMethodType = (0, typeUtils_1.partiallySpecializeType)(baseClassPropMethod, baseClassType);
|
4899
|
+
if ((0, types_1.isFunction)(baseClassMethodType)) {
|
4900
|
+
if (!subclassPropMethod) {
|
4901
|
+
// The method is missing.
|
4902
|
+
diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodMissing().format({
|
4903
|
+
name: methodName,
|
4904
|
+
}));
|
4905
|
+
const decls = overrideSymbol.getDeclarations();
|
4906
|
+
if (decls.length > 0) {
|
4907
|
+
const lastDecl = decls[decls.length - 1];
|
4908
|
+
const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
|
4909
|
+
name: memberName,
|
4910
|
+
className: baseClassType.details.name,
|
4911
|
+
}) + diagAddendum.getString(), (_a = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _a !== void 0 ? _a : lastDecl.node);
|
4912
|
+
const origDecl = baseClassMethodType.details.declaration;
|
4913
|
+
if (diag && origDecl) {
|
4914
|
+
diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
|
4915
|
+
}
|
4916
|
+
}
|
4917
|
+
}
|
4918
|
+
else {
|
4919
|
+
const subclassMethodType = (0, typeUtils_1.partiallySpecializeType)(subclassPropMethod, childClassType);
|
4920
|
+
if ((0, types_1.isFunction)(subclassMethodType)) {
|
4921
|
+
if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, childClassType, diagAddendum.createAddendum())) {
|
4922
|
+
diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodIncompatible().format({
|
4923
|
+
name: methodName,
|
4924
|
+
}));
|
4925
|
+
const decl = subclassMethodType.details.declaration;
|
4926
|
+
if (decl && decl.type === 5 /* DeclarationType.Function */) {
|
4927
|
+
const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
|
4928
|
+
name: memberName,
|
4929
|
+
className: baseClassType.details.name,
|
4930
|
+
}) + diagAddendum.getString(), decl.node.name);
|
4931
|
+
const origDecl = baseClassMethodType.details.declaration;
|
4932
|
+
if (diag && origDecl) {
|
4933
|
+
diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
|
4934
|
+
}
|
4935
|
+
}
|
4936
|
+
}
|
4937
|
+
}
|
4938
|
+
}
|
4939
|
+
}
|
4940
|
+
}
|
4941
|
+
});
|
4942
|
+
}
|
4854
4943
|
// Performs checks on a function that is located within a class
|
4855
4944
|
// and has been determined not to be a property accessor.
|
4856
4945
|
_validateMethod(node, functionType, classNode) {
|