mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Add additional test cases for F823
(#6036)
Making some behavior explicit / codified. See: https://github.com/astral-sh/ruff/issues/6029.
This commit is contained in:
parent
62ffc773de
commit
42d969f19f
3 changed files with 43 additions and 1 deletions
|
@ -39,3 +39,27 @@ class Class:
|
|||
def f(self):
|
||||
print(my_var)
|
||||
my_var = 1
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
print(sys.argv)
|
||||
|
||||
try:
|
||||
3 / 0
|
||||
except ZeroDivisionError:
|
||||
import sys
|
||||
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
print(sys.argv)
|
||||
|
||||
for sys in range(5):
|
||||
pass
|
||||
|
|
|
@ -33,7 +33,7 @@ use crate::checkers::ast::Checker;
|
|||
/// ```
|
||||
#[violation]
|
||||
pub struct UndefinedLocal {
|
||||
pub name: String,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl Violation for UndefinedLocal {
|
||||
|
|
|
@ -25,4 +25,22 @@ F823.py:40:15: F823 Local variable `my_var` referenced before assignment
|
|||
41 | my_var = 1
|
||||
|
|
||||
|
||||
F823.py:48:11: F823 Local variable `sys` referenced before assignment
|
||||
|
|
||||
47 | def main():
|
||||
48 | print(sys.argv)
|
||||
| ^^^ F823
|
||||
49 |
|
||||
50 | try:
|
||||
|
|
||||
|
||||
F823.py:62:11: F823 Local variable `sys` referenced before assignment
|
||||
|
|
||||
61 | def main():
|
||||
62 | print(sys.argv)
|
||||
| ^^^ F823
|
||||
63 |
|
||||
64 | for sys in range(5):
|
||||
|
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue