implement E307 for pylint invalid str return type (#4854)

This commit is contained in:
Ryan Yang 2023-06-05 10:54:15 -07:00 committed by GitHub
parent e6b00f0c4e
commit 72245960a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 166 additions and 11 deletions

View file

@ -907,7 +907,7 @@ pub fn resolve_imported_module_path<'a>(
/// A [`StatementVisitor`] that collects all `return` statements in a function or method.
#[derive(Default)]
pub struct ReturnStatementVisitor<'a> {
pub returns: Vec<Option<&'a Expr>>,
pub returns: Vec<&'a ast::StmtReturn>,
}
impl<'a, 'b> StatementVisitor<'b> for ReturnStatementVisitor<'a>
@ -919,10 +919,7 @@ where
Stmt::FunctionDef(_) | Stmt::AsyncFunctionDef(_) => {
// Don't recurse.
}
Stmt::Return(ast::StmtReturn {
value,
range: _range,
}) => self.returns.push(value.as_deref()),
Stmt::Return(stmt) => self.returns.push(stmt),
_ => walk_stmt(self, stmt),
}
}