Fix F811 false positive with match (#4161)
This commit is contained in:
13
crates/ruff/resources/test/fixtures/pyflakes/F811_22.py
vendored
Normal file
13
crates/ruff/resources/test/fixtures/pyflakes/F811_22.py
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
def redef(value):
|
||||
match value:
|
||||
case True:
|
||||
|
||||
def fun(x, y):
|
||||
return x
|
||||
|
||||
case False:
|
||||
|
||||
def fun(x, y):
|
||||
return y
|
||||
|
||||
return fun
|
||||
@@ -96,6 +96,7 @@ mod tests {
|
||||
#[test_case(Rule::RedefinedWhileUnused, Path::new("F811_19.py"); "F811_19")]
|
||||
#[test_case(Rule::RedefinedWhileUnused, Path::new("F811_20.py"); "F811_20")]
|
||||
#[test_case(Rule::RedefinedWhileUnused, Path::new("F811_21.py"); "F811_21")]
|
||||
#[test_case(Rule::RedefinedWhileUnused, Path::new("F811_22.py"); "F811_22")]
|
||||
#[test_case(Rule::UndefinedName, Path::new("F821_0.py"); "F821_0")]
|
||||
#[test_case(Rule::UndefinedName, Path::new("F821_1.py"); "F821_1")]
|
||||
#[test_case(Rule::UndefinedName, Path::new("F821_2.py"); "F821_2")]
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
source: crates/ruff/src/rules/pyflakes/mod.rs
|
||||
---
|
||||
|
||||
@@ -71,6 +71,10 @@ fn alternatives(stmt: RefEquality<Stmt>) -> Vec<Vec<RefEquality<Stmt>>> {
|
||||
body.iter().map(RefEquality).collect()
|
||||
}))
|
||||
.collect(),
|
||||
StmtKind::Match { cases, .. } => cases
|
||||
.iter()
|
||||
.map(|case| case.body.iter().map(RefEquality).collect())
|
||||
.collect(),
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user