Added small optimization that skips checks for overload consistency if these diagnostics are suppressed.

This commit is contained in:
Eric Traut 2024-08-07 12:06:15 -06:00
Родитель d2c0938f2b
Коммит 51c98aa945
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -2606,6 +2606,11 @@ export class Checker extends ParseTreeWalker {
// Validates that overloads use @staticmethod and @classmethod consistently.
private _validateOverloadAttributeConsistency(node: FunctionNode, functionType: OverloadedFunctionType) {
// Don't bother with the check if it's suppressed.
if (this._fileInfo.diagnosticRuleSet.reportInconsistentOverload === 'none') {
return;
}
let staticMethodCount = 0;
let classMethodCount = 0;
@ -2646,6 +2651,11 @@ export class Checker extends ParseTreeWalker {
functionType: FunctionType,
prevOverloads: FunctionType[]
) {
// Skip the check entirely if it's disabled.
if (this._fileInfo.diagnosticRuleSet.reportOverlappingOverload === 'none') {
return;
}
for (let i = 0; i < prevOverloads.length; i++) {
const prevOverload = prevOverloads[i];
if (this._isOverlappingOverload(functionType, prevOverload, /* partialOverlap */ false)) {