mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00

Implement repeated_global (FURB154) lint. See: - https://github.com/astral-sh/ruff/issues/1348 - [original lint](https://github.com/dosisod/refurb/blob/master/refurb/checks/builtin/simplify_global_and_nonlocal.py) ## Test Plan cargo test
86 lines
944 B
Python
86 lines
944 B
Python
# Errors
|
|
|
|
def f1():
|
|
global x
|
|
global y
|
|
|
|
|
|
def f3():
|
|
global x
|
|
global y
|
|
global z
|
|
|
|
|
|
def f4():
|
|
global x
|
|
global y
|
|
pass
|
|
global x
|
|
global y
|
|
|
|
|
|
def f2():
|
|
x = y = z = 1
|
|
|
|
def inner():
|
|
nonlocal x
|
|
nonlocal y
|
|
|
|
def inner2():
|
|
nonlocal x
|
|
nonlocal y
|
|
nonlocal z
|
|
|
|
def inner3():
|
|
nonlocal x
|
|
nonlocal y
|
|
pass
|
|
nonlocal x
|
|
nonlocal y
|
|
|
|
|
|
def f5():
|
|
w = x = y = z = 1
|
|
|
|
def inner():
|
|
global w
|
|
global x
|
|
nonlocal y
|
|
nonlocal z
|
|
|
|
def inner2():
|
|
global x
|
|
nonlocal y
|
|
nonlocal z
|
|
|
|
|
|
def f6():
|
|
global x, y, z
|
|
global a, b, c
|
|
global d, e, f
|
|
|
|
|
|
# Ok
|
|
|
|
def fx():
|
|
x = y = 1
|
|
|
|
def inner():
|
|
global x
|
|
nonlocal y
|
|
|
|
def inner2():
|
|
nonlocal x
|
|
pass
|
|
nonlocal y
|
|
|
|
|
|
def fy():
|
|
global x
|
|
pass
|
|
global y
|
|
|
|
|
|
def fz():
|
|
pass
|
|
global x
|