mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
Ignore ellipsis in B018 (#598)
This commit is contained in:
parent
f27163d2c7
commit
5d1ea4410a
2 changed files with 6 additions and 1 deletions
4
resources/test/fixtures/B018.py
vendored
4
resources/test/fixtures/B018.py
vendored
|
@ -53,3 +53,7 @@ def foo3():
|
|||
a = 2
|
||||
"str"
|
||||
3
|
||||
|
||||
|
||||
def foo4():
|
||||
...
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue