mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-16 11:20:22 +03:00
Enabled "noImplicitOverride" compiler flag and added missing "override" keywords.
This commit is contained in:
parent
2b4c1058eb
commit
75e570a569
@ -264,19 +264,19 @@ export class Binder extends ParseTreeWalker {
|
||||
}
|
||||
}
|
||||
|
||||
visitModule(node: ModuleNode): boolean {
|
||||
override visitModule(node: ModuleNode): boolean {
|
||||
// Tree walking should start with the children of
|
||||
// the node, so we should never get here.
|
||||
fail('We should never get here');
|
||||
return false;
|
||||
}
|
||||
|
||||
visitSuite(node: SuiteNode): boolean {
|
||||
override visitSuite(node: SuiteNode): boolean {
|
||||
this._walkStatementsAndReportUnreachable(node.statements);
|
||||
return false;
|
||||
}
|
||||
|
||||
visitModuleName(node: ModuleNameNode): boolean {
|
||||
override visitModuleName(node: ModuleNameNode): boolean {
|
||||
const importResult = AnalyzerNodeInfo.getImportInfo(node);
|
||||
assert(importResult !== undefined);
|
||||
|
||||
@ -339,7 +339,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitClass(node: ClassNode): boolean {
|
||||
override visitClass(node: ClassNode): boolean {
|
||||
this.walkMultiple(node.decorators);
|
||||
|
||||
const classDeclaration: ClassDeclaration = {
|
||||
@ -387,7 +387,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitFunction(node: FunctionNode): boolean {
|
||||
override visitFunction(node: FunctionNode): boolean {
|
||||
const symbol = this._bindNameToScope(this._currentScope, node.name.value);
|
||||
const containingClassNode = ParseTreeUtils.getEnclosingClass(node, true);
|
||||
const functionDeclaration: FunctionDeclaration = {
|
||||
@ -515,7 +515,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitLambda(node: LambdaNode): boolean {
|
||||
override visitLambda(node: LambdaNode): boolean {
|
||||
// Analyze the parameter defaults in the context of the parent's scope
|
||||
// before we add any names from the function's scope.
|
||||
node.parameters.forEach((param) => {
|
||||
@ -567,7 +567,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitCall(node: CallNode): boolean {
|
||||
override visitCall(node: CallNode): boolean {
|
||||
this.walk(node.leftExpression);
|
||||
this.walkMultiple(node.arguments);
|
||||
this._createCallFlowNode(node);
|
||||
@ -649,7 +649,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitAssignment(node: AssignmentNode): boolean {
|
||||
override visitAssignment(node: AssignmentNode): boolean {
|
||||
if (this._handleTypingStubAssignmentOrAnnotation(node)) {
|
||||
return false;
|
||||
}
|
||||
@ -736,7 +736,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitAssignmentExpression(node: AssignmentExpressionNode) {
|
||||
override visitAssignmentExpression(node: AssignmentExpressionNode) {
|
||||
// Temporarily disable true/false targets in case this assignment
|
||||
// expression is located within an if/else conditional.
|
||||
this._disableTrueFalseTargets(() => {
|
||||
@ -780,7 +780,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitAugmentedAssignment(node: AugmentedAssignmentNode) {
|
||||
override visitAugmentedAssignment(node: AugmentedAssignmentNode) {
|
||||
this.walk(node.leftExpression);
|
||||
this.walk(node.rightExpression);
|
||||
|
||||
@ -841,7 +841,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitDel(node: DelNode) {
|
||||
override visitDel(node: DelNode) {
|
||||
node.expressions.forEach((expr) => {
|
||||
this._bindPossibleTupleNamedTarget(expr);
|
||||
this.walk(expr);
|
||||
@ -851,7 +851,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitTypeAnnotation(node: TypeAnnotationNode): boolean {
|
||||
override visitTypeAnnotation(node: TypeAnnotationNode): boolean {
|
||||
if (this._handleTypingStubAssignmentOrAnnotation(node)) {
|
||||
return false;
|
||||
}
|
||||
@ -880,7 +880,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitFor(node: ForNode) {
|
||||
override visitFor(node: ForNode) {
|
||||
this._bindPossibleTupleNamedTarget(node.targetExpression);
|
||||
this._addInferredTypeAssignmentForVariable(node.targetExpression, node);
|
||||
|
||||
@ -918,7 +918,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitContinue(node: ContinueNode): boolean {
|
||||
override visitContinue(node: ContinueNode): boolean {
|
||||
if (this._currentContinueTarget) {
|
||||
this._addAntecedent(this._currentContinueTarget, this._currentFlowNode!);
|
||||
}
|
||||
@ -928,7 +928,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitBreak(node: BreakNode): boolean {
|
||||
override visitBreak(node: BreakNode): boolean {
|
||||
if (this._currentBreakTarget) {
|
||||
this._addAntecedent(this._currentBreakTarget, this._currentFlowNode!);
|
||||
}
|
||||
@ -938,7 +938,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitReturn(node: ReturnNode): boolean {
|
||||
override visitReturn(node: ReturnNode): boolean {
|
||||
if (this._targetFunctionDeclaration) {
|
||||
if (!this._targetFunctionDeclaration.returnStatements) {
|
||||
this._targetFunctionDeclaration.returnStatements = [];
|
||||
@ -961,7 +961,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitYield(node: YieldNode): boolean {
|
||||
override visitYield(node: YieldNode): boolean {
|
||||
if (this._isInListComprehension(node)) {
|
||||
this._addError(Localizer.Diagnostic.yieldWithinListCompr(), node);
|
||||
}
|
||||
@ -970,7 +970,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitYieldFrom(node: YieldFromNode): boolean {
|
||||
override visitYieldFrom(node: YieldFromNode): boolean {
|
||||
if (this._isInListComprehension(node)) {
|
||||
this._addError(Localizer.Diagnostic.yieldWithinListCompr(), node);
|
||||
}
|
||||
@ -979,24 +979,24 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitMemberAccess(node: MemberAccessNode): boolean {
|
||||
override visitMemberAccess(node: MemberAccessNode): boolean {
|
||||
AnalyzerNodeInfo.setFlowNode(node, this._currentFlowNode!);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitName(node: NameNode): boolean {
|
||||
override visitName(node: NameNode): boolean {
|
||||
AnalyzerNodeInfo.setFlowNode(node, this._currentFlowNode!);
|
||||
|
||||
// Name nodes have no children.
|
||||
return false;
|
||||
}
|
||||
|
||||
visitIndex(node: IndexNode): boolean {
|
||||
override visitIndex(node: IndexNode): boolean {
|
||||
AnalyzerNodeInfo.setFlowNode(node, this._currentFlowNode!);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitIf(node: IfNode): boolean {
|
||||
override visitIf(node: IfNode): boolean {
|
||||
const thenLabel = this._createBranchLabel();
|
||||
const elseLabel = this._createBranchLabel();
|
||||
const postIfLabel = this._createBranchLabel();
|
||||
@ -1034,7 +1034,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitWhile(node: WhileNode): boolean {
|
||||
override visitWhile(node: WhileNode): boolean {
|
||||
const thenLabel = this._createBranchLabel();
|
||||
const elseLabel = this._createBranchLabel();
|
||||
const postWhileLabel = this._createBranchLabel();
|
||||
@ -1072,7 +1072,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitAssert(node: AssertNode): boolean {
|
||||
override visitAssert(node: AssertNode): boolean {
|
||||
const assertTrueLabel = this._createBranchLabel();
|
||||
const assertFalseLabel = this._createBranchLabel();
|
||||
|
||||
@ -1087,7 +1087,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitExcept(node: ExceptNode): boolean {
|
||||
override visitExcept(node: ExceptNode): boolean {
|
||||
if (node.typeExpression) {
|
||||
this.walk(node.typeExpression);
|
||||
}
|
||||
@ -1122,7 +1122,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitRaise(node: RaiseNode): boolean {
|
||||
override visitRaise(node: RaiseNode): boolean {
|
||||
if (this._targetFunctionDeclaration) {
|
||||
if (!this._targetFunctionDeclaration.raiseStatements) {
|
||||
this._targetFunctionDeclaration.raiseStatements = [];
|
||||
@ -1148,7 +1148,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitTry(node: TryNode): boolean {
|
||||
override visitTry(node: TryNode): boolean {
|
||||
// The try/except/else/finally statement is tricky to model using static code
|
||||
// flow rules because the finally clause is executed regardless of whether an
|
||||
// exception is raised or a return statement is executed. Code within the finally
|
||||
@ -1276,7 +1276,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitAwait(node: AwaitNode) {
|
||||
override visitAwait(node: AwaitNode) {
|
||||
// Make sure this is within an async lambda or function.
|
||||
const enclosingFunction = ParseTreeUtils.getEnclosingFunction(node);
|
||||
if (enclosingFunction === undefined || !enclosingFunction.isAsync) {
|
||||
@ -1291,7 +1291,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitGlobal(node: GlobalNode): boolean {
|
||||
override visitGlobal(node: GlobalNode): boolean {
|
||||
const globalScope = this._currentScope.getGlobalScope();
|
||||
|
||||
node.nameList.forEach((name) => {
|
||||
@ -1320,7 +1320,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitNonlocal(node: NonlocalNode): boolean {
|
||||
override visitNonlocal(node: NonlocalNode): boolean {
|
||||
const globalScope = this._currentScope.getGlobalScope();
|
||||
|
||||
if (this._currentScope === globalScope) {
|
||||
@ -1352,7 +1352,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitImportAs(node: ImportAsNode): boolean {
|
||||
override visitImportAs(node: ImportAsNode): boolean {
|
||||
if (node.module.nameParts.length > 0) {
|
||||
const firstNamePartValue = node.module.nameParts[0].value;
|
||||
|
||||
@ -1405,7 +1405,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitImportFrom(node: ImportFromNode): boolean {
|
||||
override visitImportFrom(node: ImportFromNode): boolean {
|
||||
const typingSymbolsOfInterest = ['Final', 'TypeAlias', 'ClassVar', 'Required', 'NotRequired'];
|
||||
const importInfo = AnalyzerNodeInfo.getImportInfo(node.module);
|
||||
|
||||
@ -1609,7 +1609,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitWith(node: WithNode): boolean {
|
||||
override visitWith(node: WithNode): boolean {
|
||||
node.withItems.forEach((item) => {
|
||||
this.walk(item.expression);
|
||||
if (item.target) {
|
||||
@ -1667,7 +1667,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitTernary(node: TernaryNode): boolean {
|
||||
override visitTernary(node: TernaryNode): boolean {
|
||||
const trueLabel = this._createBranchLabel();
|
||||
const falseLabel = this._createBranchLabel();
|
||||
const postExpressionLabel = this._createBranchLabel();
|
||||
@ -1690,7 +1690,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitUnaryOperation(node: UnaryOperationNode): boolean {
|
||||
override visitUnaryOperation(node: UnaryOperationNode): boolean {
|
||||
if (node.operator === OperatorType.Not && this._currentFalseTarget && this._currentTrueTarget) {
|
||||
// Swap the existing true/false targets.
|
||||
this._bindConditional(node.expression, this._currentFalseTarget, this._currentTrueTarget);
|
||||
@ -1707,7 +1707,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitBinaryOperation(node: BinaryOperationNode): boolean {
|
||||
override visitBinaryOperation(node: BinaryOperationNode): boolean {
|
||||
if (node.operator === OperatorType.And || node.operator === OperatorType.Or) {
|
||||
let trueTarget = this._currentTrueTarget;
|
||||
let falseTarget = this._currentFalseTarget;
|
||||
@ -1742,7 +1742,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitListComprehension(node: ListComprehensionNode): boolean {
|
||||
override visitListComprehension(node: ListComprehensionNode): boolean {
|
||||
const enclosingFunction = ParseTreeUtils.getEnclosingFunction(node);
|
||||
|
||||
this._createNewScope(ScopeType.ListComprehension, this._currentScope, () => {
|
||||
@ -1813,7 +1813,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitMatch(node: MatchNode) {
|
||||
override visitMatch(node: MatchNode) {
|
||||
// Evaluate the subject expression.
|
||||
this.walk(node.subjectExpression);
|
||||
|
||||
@ -1890,7 +1890,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitPatternAs(node: PatternAsNode) {
|
||||
override visitPatternAs(node: PatternAsNode) {
|
||||
const postOrLabel = this._createBranchLabel();
|
||||
|
||||
node.orPatterns.forEach((orPattern) => {
|
||||
@ -1926,7 +1926,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitPatternCapture(node: PatternCaptureNode) {
|
||||
override visitPatternCapture(node: PatternCaptureNode) {
|
||||
if (!node.isWildcard) {
|
||||
this._addPatternCaptureTarget(node.target);
|
||||
}
|
||||
@ -1934,7 +1934,7 @@ export class Binder extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitPatternMappingExpandEntry(node: PatternMappingExpandEntryNode) {
|
||||
override visitPatternMappingExpandEntry(node: PatternMappingExpandEntryNode) {
|
||||
if (node.target.value !== '_') {
|
||||
this._addPatternCaptureTarget(node.target);
|
||||
}
|
||||
@ -3536,12 +3536,12 @@ export class YieldFinder extends ParseTreeWalker {
|
||||
return this._containsYield;
|
||||
}
|
||||
|
||||
visitYield(node: YieldNode): boolean {
|
||||
override visitYield(node: YieldNode): boolean {
|
||||
this._containsYield = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
visitYieldFrom(node: YieldFromNode): boolean {
|
||||
override visitYieldFrom(node: YieldFromNode): boolean {
|
||||
this._containsYield = true;
|
||||
return false;
|
||||
}
|
||||
@ -3555,7 +3555,7 @@ export class ReturnFinder extends ParseTreeWalker {
|
||||
return this._containsReturn;
|
||||
}
|
||||
|
||||
visitReturn(node: ReturnNode): boolean {
|
||||
override visitReturn(node: ReturnNode): boolean {
|
||||
this._containsReturn = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ export class Checker extends ParseTreeWalker {
|
||||
this._reportDuplicateImports();
|
||||
}
|
||||
|
||||
walk(node: ParseNode) {
|
||||
override walk(node: ParseNode) {
|
||||
if (!AnalyzerNodeInfo.isCodeUnreachable(node)) {
|
||||
super.walk(node);
|
||||
} else {
|
||||
@ -189,12 +189,12 @@ export class Checker extends ParseTreeWalker {
|
||||
}
|
||||
}
|
||||
|
||||
visitSuite(node: SuiteNode): boolean {
|
||||
override visitSuite(node: SuiteNode): boolean {
|
||||
this._walkStatementsAndReportUnreachable(node.statements);
|
||||
return false;
|
||||
}
|
||||
|
||||
visitStatementList(node: StatementListNode) {
|
||||
override visitStatementList(node: StatementListNode) {
|
||||
node.statements.forEach((statement) => {
|
||||
if (isExpressionNode(statement)) {
|
||||
// Evaluate the expression in case it wasn't otherwise evaluated
|
||||
@ -207,7 +207,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitClass(node: ClassNode): boolean {
|
||||
override visitClass(node: ClassNode): boolean {
|
||||
const classTypeResult = this._evaluator.getTypeOfClass(node);
|
||||
|
||||
this.walk(node.suite);
|
||||
@ -260,7 +260,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitFunction(node: FunctionNode): boolean {
|
||||
override visitFunction(node: FunctionNode): boolean {
|
||||
const functionTypeResult = this._evaluator.getTypeOfFunction(node);
|
||||
const containingClassNode = ParseTreeUtils.getEnclosingClass(node, true);
|
||||
|
||||
@ -489,7 +489,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitLambda(node: LambdaNode): boolean {
|
||||
override visitLambda(node: LambdaNode): boolean {
|
||||
this._evaluator.getType(node);
|
||||
|
||||
// Walk the children.
|
||||
@ -544,7 +544,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitCall(node: CallNode): boolean {
|
||||
override visitCall(node: CallNode): boolean {
|
||||
this._validateIsInstanceCall(node);
|
||||
|
||||
if (ParseTreeUtils.isWithinDefaultParamInitializer(node) && !this._fileInfo.isStubFile) {
|
||||
@ -588,7 +588,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitAwait(node: AwaitNode) {
|
||||
override visitAwait(node: AwaitNode) {
|
||||
if (this._fileInfo.diagnosticRuleSet.reportUnusedCallResult !== 'none') {
|
||||
if (
|
||||
node.parent?.nodeType === ParseNodeType.StatementList &&
|
||||
@ -612,27 +612,27 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitFor(node: ForNode): boolean {
|
||||
override visitFor(node: ForNode): boolean {
|
||||
this._evaluator.evaluateTypesForStatement(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitListComprehension(node: ListComprehensionNode): boolean {
|
||||
override visitListComprehension(node: ListComprehensionNode): boolean {
|
||||
this._scopedNodes.push(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitIf(node: IfNode): boolean {
|
||||
override visitIf(node: IfNode): boolean {
|
||||
this._evaluator.getType(node.testExpression);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitWhile(node: WhileNode): boolean {
|
||||
override visitWhile(node: WhileNode): boolean {
|
||||
this._evaluator.getType(node.testExpression);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitWith(node: WithNode): boolean {
|
||||
override visitWith(node: WithNode): boolean {
|
||||
node.withItems.forEach((item) => {
|
||||
this._evaluator.evaluateTypesForStatement(item);
|
||||
});
|
||||
@ -640,7 +640,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitReturn(node: ReturnNode): boolean {
|
||||
override visitReturn(node: ReturnNode): boolean {
|
||||
let returnType: Type;
|
||||
|
||||
const enclosingFunctionNode = ParseTreeUtils.getEnclosingFunction(node);
|
||||
@ -711,13 +711,13 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitYield(node: YieldNode) {
|
||||
override visitYield(node: YieldNode) {
|
||||
const yieldType = node.expression ? this._evaluator.getType(node.expression) : NoneType.createInstance();
|
||||
this._validateYieldType(node, yieldType || UnknownType.create());
|
||||
return true;
|
||||
}
|
||||
|
||||
visitYieldFrom(node: YieldFromNode) {
|
||||
override visitYieldFrom(node: YieldFromNode) {
|
||||
const yieldFromType = this._evaluator.getType(node.expression) || UnknownType.create();
|
||||
let yieldType =
|
||||
this._evaluator.getTypeFromIterable(yieldFromType, /* isAsync */ false, node) || UnknownType.create();
|
||||
@ -738,7 +738,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitRaise(node: RaiseNode): boolean {
|
||||
override visitRaise(node: RaiseNode): boolean {
|
||||
this._evaluator.verifyRaiseExceptionType(node);
|
||||
|
||||
if (node.valueExpression) {
|
||||
@ -789,7 +789,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitExcept(node: ExceptNode): boolean {
|
||||
override visitExcept(node: ExceptNode): boolean {
|
||||
if (node.typeExpression) {
|
||||
this._evaluator.evaluateTypesForStatement(node);
|
||||
|
||||
@ -802,7 +802,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitAssert(node: AssertNode) {
|
||||
override visitAssert(node: AssertNode) {
|
||||
if (node.exceptionExpression) {
|
||||
this._evaluator.getType(node.exceptionExpression);
|
||||
}
|
||||
@ -830,7 +830,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitAssignment(node: AssignmentNode): boolean {
|
||||
override visitAssignment(node: AssignmentNode): boolean {
|
||||
this._evaluator.evaluateTypesForStatement(node);
|
||||
if (node.typeAnnotationComment) {
|
||||
this._evaluator.getType(node.typeAnnotationComment);
|
||||
@ -839,17 +839,17 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitAssignmentExpression(node: AssignmentExpressionNode): boolean {
|
||||
override visitAssignmentExpression(node: AssignmentExpressionNode): boolean {
|
||||
this._evaluator.getType(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitAugmentedAssignment(node: AugmentedAssignmentNode): boolean {
|
||||
override visitAugmentedAssignment(node: AugmentedAssignmentNode): boolean {
|
||||
this._evaluator.evaluateTypesForStatement(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitIndex(node: IndexNode): boolean {
|
||||
override visitIndex(node: IndexNode): boolean {
|
||||
this._evaluator.getType(node);
|
||||
|
||||
// If the index is a literal integer, see if this is a tuple with
|
||||
@ -899,7 +899,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitBinaryOperation(node: BinaryOperationNode): boolean {
|
||||
override visitBinaryOperation(node: BinaryOperationNode): boolean {
|
||||
if (node.operator === OperatorType.Equals || node.operator === OperatorType.NotEquals) {
|
||||
// Don't apply this rule if it's within an assert.
|
||||
if (!ParseTreeUtils.isWithinAssertExpression(node)) {
|
||||
@ -911,32 +911,32 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitSlice(node: SliceNode): boolean {
|
||||
override visitSlice(node: SliceNode): boolean {
|
||||
this._evaluator.getType(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitUnpack(node: UnpackNode): boolean {
|
||||
override visitUnpack(node: UnpackNode): boolean {
|
||||
this._evaluator.getType(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitTuple(node: TupleNode): boolean {
|
||||
override visitTuple(node: TupleNode): boolean {
|
||||
this._evaluator.getType(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitUnaryOperation(node: UnaryOperationNode): boolean {
|
||||
override visitUnaryOperation(node: UnaryOperationNode): boolean {
|
||||
this._evaluator.getType(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitTernary(node: TernaryNode): boolean {
|
||||
override visitTernary(node: TernaryNode): boolean {
|
||||
this._evaluator.getType(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitStringList(node: StringListNode): boolean {
|
||||
override visitStringList(node: StringListNode): boolean {
|
||||
for (const stringNode of node.strings) {
|
||||
if (stringNode.hasUnescapeErrors) {
|
||||
const unescapedResult = getUnescapedString(stringNode.token);
|
||||
@ -1003,7 +1003,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitFormatString(node: FormatStringNode): boolean {
|
||||
override visitFormatString(node: FormatStringNode): boolean {
|
||||
node.expressions.forEach((formatExpr) => {
|
||||
this._evaluator.getType(formatExpr);
|
||||
});
|
||||
@ -1011,27 +1011,27 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitGlobal(node: GlobalNode): boolean {
|
||||
override visitGlobal(node: GlobalNode): boolean {
|
||||
node.nameList.forEach((name) => {
|
||||
this._evaluator.getType(name);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
visitNonlocal(node: NonlocalNode): boolean {
|
||||
override visitNonlocal(node: NonlocalNode): boolean {
|
||||
node.nameList.forEach((name) => {
|
||||
this._evaluator.getType(name);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
visitName(node: NameNode) {
|
||||
override visitName(node: NameNode) {
|
||||
// Determine if we should log information about private usage.
|
||||
this._conditionallyReportPrivateUsage(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitDel(node: DelNode) {
|
||||
override visitDel(node: DelNode) {
|
||||
node.expressions.forEach((expr) => {
|
||||
this._evaluator.verifyDeleteExpression(expr);
|
||||
});
|
||||
@ -1039,7 +1039,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitMemberAccess(node: MemberAccessNode) {
|
||||
override visitMemberAccess(node: MemberAccessNode) {
|
||||
this._evaluator.getType(node);
|
||||
this._conditionallyReportPrivateUsage(node.memberName);
|
||||
|
||||
@ -1049,12 +1049,12 @@ export class Checker extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitImportAs(node: ImportAsNode): boolean {
|
||||
override visitImportAs(node: ImportAsNode): boolean {
|
||||
this._evaluator.evaluateTypesForStatement(node);
|
||||
return false;
|
||||
}
|
||||
|
||||
visitImportFrom(node: ImportFromNode): boolean {
|
||||
override visitImportFrom(node: ImportFromNode): boolean {
|
||||
if (!node.isWildcardImport) {
|
||||
node.imports.forEach((importAs) => {
|
||||
this._evaluator.evaluateTypesForStatement(importAs);
|
||||
@ -1080,17 +1080,17 @@ export class Checker extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitTypeAnnotation(node: TypeAnnotationNode): boolean {
|
||||
override visitTypeAnnotation(node: TypeAnnotationNode): boolean {
|
||||
this._evaluator.getType(node.typeAnnotation);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitMatch(node: MatchNode): boolean {
|
||||
override visitMatch(node: MatchNode): boolean {
|
||||
this._evaluator.getType(node.subjectExpression);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitCase(node: CaseNode): boolean {
|
||||
override visitCase(node: CaseNode): boolean {
|
||||
if (node.guardExpression) {
|
||||
this._evaluator.getType(node.guardExpression);
|
||||
}
|
||||
@ -1099,7 +1099,7 @@ export class Checker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitError(node: ErrorNode) {
|
||||
override visitError(node: ErrorNode) {
|
||||
// Get the type of the child so it's available to
|
||||
// the completion provider.
|
||||
if (node.child) {
|
||||
|
@ -28,7 +28,7 @@ export class ParseTreeCleanerWalker extends ParseTreeWalker {
|
||||
this.walk(this._parseTree);
|
||||
}
|
||||
|
||||
visitNode(node: ParseNode) {
|
||||
override visitNode(node: ParseNode) {
|
||||
AnalyzerNodeInfo.cleanNodeAnalysisInfo(node);
|
||||
return super.visitNode(node);
|
||||
}
|
||||
|
@ -1213,12 +1213,12 @@ export class NameNodeWalker extends ParseTreeWalker {
|
||||
super();
|
||||
}
|
||||
|
||||
visitName(node: NameNode) {
|
||||
override visitName(node: NameNode) {
|
||||
this._callback(node, this._subscriptIndex, this._baseExpression);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitIndex(node: IndexNode) {
|
||||
override visitIndex(node: IndexNode) {
|
||||
this.walk(node.baseExpression);
|
||||
|
||||
const prevSubscriptIndex = this._subscriptIndex;
|
||||
|
@ -15,7 +15,7 @@ export class TestWalker extends ParseTreeWalker {
|
||||
super();
|
||||
}
|
||||
|
||||
visitNode(node: ParseNode) {
|
||||
override visitNode(node: ParseNode) {
|
||||
const children = super.visitNode(node);
|
||||
this._verifyParentChildLinks(node, children);
|
||||
this._verifyChildRanges(node, children);
|
||||
@ -90,7 +90,7 @@ export class NameTypeWalker extends ParseTreeWalker {
|
||||
super();
|
||||
}
|
||||
|
||||
visitName(node: NameNode) {
|
||||
override visitName(node: NameNode) {
|
||||
if (node.parent?.nodeType !== ParseNodeType.ImportFromAs && node.parent?.nodeType !== ParseNodeType.ImportAs) {
|
||||
if (this._evaluator.isNodeReachable(node)) {
|
||||
this._evaluator.getType(node);
|
||||
|
@ -90,18 +90,18 @@ class ImportSymbolWalker extends ParseTreeWalker {
|
||||
this.walk(node);
|
||||
}
|
||||
|
||||
walk(node: ParseNode) {
|
||||
override walk(node: ParseNode) {
|
||||
if (!AnalyzerNodeInfo.isCodeUnreachable(node)) {
|
||||
super.walk(node);
|
||||
}
|
||||
}
|
||||
|
||||
visitName(node: NameNode) {
|
||||
override visitName(node: NameNode) {
|
||||
this._accessedImportedSymbols.set(node.value, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
visitString(node: StringNode) {
|
||||
override visitString(node: StringNode) {
|
||||
if (this._treatStringsAsSymbols) {
|
||||
this._accessedImportedSymbols.set(node.value, true);
|
||||
}
|
||||
@ -146,13 +146,13 @@ export class TypeStubWriter extends ParseTreeWalker {
|
||||
this._writeFile();
|
||||
}
|
||||
|
||||
walk(node: ParseNode) {
|
||||
override walk(node: ParseNode) {
|
||||
if (!AnalyzerNodeInfo.isCodeUnreachable(node)) {
|
||||
super.walk(node);
|
||||
}
|
||||
}
|
||||
|
||||
visitClass(node: ClassNode) {
|
||||
override visitClass(node: ClassNode) {
|
||||
const className = node.name.value;
|
||||
|
||||
this._emittedSuite = true;
|
||||
@ -196,7 +196,7 @@ export class TypeStubWriter extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitFunction(node: FunctionNode) {
|
||||
override visitFunction(node: FunctionNode) {
|
||||
const functionName = node.name.value;
|
||||
|
||||
// Skip if we're already within a function or if the name is private/protected.
|
||||
@ -267,31 +267,31 @@ export class TypeStubWriter extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitWhile(node: WhileNode) {
|
||||
override visitWhile(node: WhileNode) {
|
||||
// Don't emit a doc string after the first statement.
|
||||
this._emitDocString = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
visitFor(node: ForNode) {
|
||||
override visitFor(node: ForNode) {
|
||||
// Don't emit a doc string after the first statement.
|
||||
this._emitDocString = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
visitTry(node: TryNode) {
|
||||
override visitTry(node: TryNode) {
|
||||
// Don't emit a doc string after the first statement.
|
||||
this._emitDocString = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
visitWith(node: WithNode) {
|
||||
override visitWith(node: WithNode) {
|
||||
// Don't emit a doc string after the first statement.
|
||||
this._emitDocString = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
visitIf(node: IfNode) {
|
||||
override visitIf(node: IfNode) {
|
||||
// Don't emit a doc string after the first statement.
|
||||
this._emitDocString = false;
|
||||
|
||||
@ -322,7 +322,7 @@ export class TypeStubWriter extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitAssignment(node: AssignmentNode) {
|
||||
override visitAssignment(node: AssignmentNode) {
|
||||
let isTypeAlias = false;
|
||||
let line = '';
|
||||
|
||||
@ -372,11 +372,11 @@ export class TypeStubWriter extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitAugmentedAssignment(node: AugmentedAssignmentNode) {
|
||||
override visitAugmentedAssignment(node: AugmentedAssignmentNode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitTypeAnnotation(node: TypeAnnotationNode) {
|
||||
override visitTypeAnnotation(node: TypeAnnotationNode) {
|
||||
if (this._functionNestCount === 0) {
|
||||
let line = '';
|
||||
if (node.valueExpression.nodeType === ParseNodeType.Name) {
|
||||
@ -402,7 +402,7 @@ export class TypeStubWriter extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitImport(node: ImportNode) {
|
||||
override visitImport(node: ImportNode) {
|
||||
if (this._functionNestCount > 0 || this._classNestCount > 0) {
|
||||
return false;
|
||||
}
|
||||
@ -434,7 +434,7 @@ export class TypeStubWriter extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitImportFrom(node: ImportFromNode) {
|
||||
override visitImportFrom(node: ImportFromNode) {
|
||||
if (this._functionNestCount > 0 || this._classNestCount > 0) {
|
||||
return false;
|
||||
}
|
||||
@ -466,7 +466,7 @@ export class TypeStubWriter extends ParseTreeWalker {
|
||||
return false;
|
||||
}
|
||||
|
||||
visitStatementList(node: StatementListNode) {
|
||||
override visitStatementList(node: StatementListNode) {
|
||||
if (node.statements.length > 0 && node.statements[0].nodeType === ParseNodeType.StringList) {
|
||||
// Is this the first statement in a suite? If it's a string
|
||||
// literal, assume it's a doc string and emit it.
|
||||
|
@ -51,7 +51,7 @@ class FileBasedToken implements CancellationToken {
|
||||
|
||||
constructor(readonly cancellationFilePath: string) {}
|
||||
|
||||
public cancel() {
|
||||
cancel() {
|
||||
if (!this.isCancelled) {
|
||||
this.isCancelled = true;
|
||||
if (this._emitter) {
|
||||
@ -84,7 +84,7 @@ class FileBasedToken implements CancellationToken {
|
||||
return this._emitter.event;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
dispose(): void {
|
||||
this._disposeEmitter();
|
||||
}
|
||||
|
||||
@ -112,20 +112,20 @@ class OwningFileToken extends FileBasedToken {
|
||||
super(cancellationFilePath);
|
||||
}
|
||||
|
||||
public cancel() {
|
||||
override cancel() {
|
||||
if (!this._disposed && !this.isCancelled) {
|
||||
this._createPipe();
|
||||
super.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
get isCancellationRequested(): boolean {
|
||||
override get isCancellationRequested(): boolean {
|
||||
// Since this object owns the file and it gets created when the
|
||||
// token is cancelled, there's no point in checking the pipe.
|
||||
return this.isCancelled;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
override dispose(): void {
|
||||
this._disposed = true;
|
||||
|
||||
super.dispose();
|
||||
|
@ -190,12 +190,12 @@ function hasZipMagic(fs: FakeFS<PortablePath>, p: PortablePath): boolean {
|
||||
//@ts-expect-error
|
||||
class EggZipOpenFS extends ZipOpenFS {
|
||||
// Copied from the ZipOpenFS implementation.
|
||||
private readonly baseFs!: FakeFS<PortablePath>;
|
||||
private readonly filter!: RegExp | null;
|
||||
private isZip!: Set<PortablePath>;
|
||||
private notZip!: Set<PortablePath>;
|
||||
private override readonly baseFs!: FakeFS<PortablePath>;
|
||||
private override readonly filter!: RegExp | null;
|
||||
private override isZip!: Set<PortablePath>;
|
||||
private override notZip!: Set<PortablePath>;
|
||||
|
||||
findZip(p: PortablePath) {
|
||||
override findZip(p: PortablePath) {
|
||||
if (this.filter && !this.filter.test(p)) return null;
|
||||
|
||||
let filePath = `` as PortablePath;
|
||||
|
@ -175,7 +175,7 @@ class FindOutgoingCallTreeWalker extends ParseTreeWalker {
|
||||
return this._outgoingCalls;
|
||||
}
|
||||
|
||||
visitCall(node: CallNode): boolean {
|
||||
override visitCall(node: CallNode): boolean {
|
||||
throwIfCancellationRequested(this._cancellationToken);
|
||||
|
||||
let nameNode: NameNode | undefined;
|
||||
@ -202,7 +202,7 @@ class FindOutgoingCallTreeWalker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitMemberAccess(node: MemberAccessNode): boolean {
|
||||
override visitMemberAccess(node: MemberAccessNode): boolean {
|
||||
throwIfCancellationRequested(this._cancellationToken);
|
||||
|
||||
// Determine whether the member corresponds to a property.
|
||||
@ -303,7 +303,7 @@ class FindIncomingCallTreeWalker extends ParseTreeWalker {
|
||||
return this._incomingCalls;
|
||||
}
|
||||
|
||||
visitCall(node: CallNode): boolean {
|
||||
override visitCall(node: CallNode): boolean {
|
||||
throwIfCancellationRequested(this._cancellationToken);
|
||||
|
||||
let nameNode: NameNode | undefined;
|
||||
@ -333,7 +333,7 @@ class FindIncomingCallTreeWalker extends ParseTreeWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
visitMemberAccess(node: MemberAccessNode): boolean {
|
||||
override visitMemberAccess(node: MemberAccessNode): boolean {
|
||||
throwIfCancellationRequested(this._cancellationToken);
|
||||
|
||||
if (node.memberName.value === this._symbolName) {
|
||||
|
@ -40,18 +40,18 @@ class HighlightSymbolTreeWalker extends ParseTreeWalker {
|
||||
this.walk(this._parseResults.parseTree);
|
||||
}
|
||||
|
||||
walk(node: ParseNode) {
|
||||
override walk(node: ParseNode) {
|
||||
if (!isCodeUnreachable(node)) {
|
||||
super.walk(node);
|
||||
}
|
||||
}
|
||||
|
||||
visitModuleName(node: ModuleNameNode): boolean {
|
||||
override visitModuleName(node: ModuleNameNode): boolean {
|
||||
// Don't ever look for references within a module name.
|
||||
return false;
|
||||
}
|
||||
|
||||
visitName(node: NameNode): boolean {
|
||||
override visitName(node: NameNode): boolean {
|
||||
throwIfCancellationRequested(this._cancellationToken);
|
||||
|
||||
// No need to do any more work if the symbol name doesn't match.
|
||||
|
@ -74,18 +74,18 @@ export class FindReferencesTreeWalker extends ParseTreeWalker {
|
||||
return this._locationsFound;
|
||||
}
|
||||
|
||||
walk(node: ParseNode) {
|
||||
override walk(node: ParseNode) {
|
||||
if (!AnalyzerNodeInfo.isCodeUnreachable(node)) {
|
||||
super.walk(node);
|
||||
}
|
||||
}
|
||||
|
||||
visitModuleName(node: ModuleNameNode): boolean {
|
||||
override visitModuleName(node: ModuleNameNode): boolean {
|
||||
// Don't ever look for references within a module name.
|
||||
return false;
|
||||
}
|
||||
|
||||
visitName(node: NameNode): boolean {
|
||||
override visitName(node: NameNode): boolean {
|
||||
throwIfCancellationRequested(this._cancellationToken);
|
||||
|
||||
// No need to do any more work if the symbol name doesn't match.
|
||||
|
@ -354,35 +354,38 @@ export class PyrightFileSystem implements FileSystem {
|
||||
}
|
||||
|
||||
class FakeFile extends fs.Dirent {
|
||||
constructor(public name: string) {
|
||||
override name: string;
|
||||
|
||||
constructor(name: string) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
isFile(): boolean {
|
||||
override isFile(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
isDirectory(): boolean {
|
||||
override isDirectory(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
isBlockDevice(): boolean {
|
||||
override isBlockDevice(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
isCharacterDevice(): boolean {
|
||||
override isCharacterDevice(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
isSymbolicLink(): boolean {
|
||||
override isSymbolicLink(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
isFIFO(): boolean {
|
||||
override isFIFO(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
isSocket(): boolean {
|
||||
override isSocket(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ class PyrightServer extends LanguageServerBase {
|
||||
return this._controller.execute(params, token);
|
||||
}
|
||||
|
||||
protected isLongRunningCommand(command: string): boolean {
|
||||
protected override isLongRunningCommand(command: string): boolean {
|
||||
return this._controller.isLongRunningCommand(command);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
"sourceMap": true,
|
||||
"outDir": "./out",
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitOverride": true,
|
||||
"checkJs": true,
|
||||
},
|
||||
"exclude": [
|
||||
@ -22,4 +23,4 @@
|
||||
"dist",
|
||||
"out"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user