Ignore ellipsis in B018 (#598)

This commit is contained in:
Harutaka Kawamura 2022-11-06 03:11:44 +09:00 committed by GitHub
parent f27163d2c7
commit 5d1ea4410a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -53,3 +53,7 @@ def foo3():
a = 2
"str"
3
def foo4():
...

View file

@ -4,6 +4,7 @@ use crate::ast::types::{CheckLocator, Range};
use crate::check_ast::Checker;
use crate::checks::{Check, CheckKind};
// B018
pub fn useless_expression(checker: &mut Checker, body: &[Stmt]) {
for stmt in body {
if let StmtKind::Expr { value } = &stmt.node {
@ -15,7 +16,7 @@ pub fn useless_expression(checker: &mut Checker, body: &[Stmt]) {
));
}
ExprKind::Constant { value: val, .. } => match &val {
Constant::Str { .. } => {}
Constant::Str { .. } | Constant::Ellipsis => {}
_ => {
checker.add_check(Check::new(
CheckKind::UselessExpression,