mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:53 +00:00

## Summary Resolves #16445. `UP028` is now no longer always fixable: it will not offer a fix when at least one `ExprName` target is bound to either a `global` or a `nonlocal` declaration. ## Test Plan `cargo nextest run` and `cargo insta test`.
142 lines
1.5 KiB
Python
142 lines
1.5 KiB
Python
# OK
|
|
def f():
|
|
for x in z:
|
|
yield
|
|
|
|
|
|
def f():
|
|
for x in z:
|
|
yield y
|
|
|
|
|
|
def f():
|
|
for x, y in z:
|
|
yield x
|
|
|
|
|
|
def f():
|
|
for x, y in z:
|
|
yield y
|
|
|
|
|
|
def f():
|
|
for a, b in z:
|
|
yield x, y
|
|
|
|
|
|
def f():
|
|
for x, y in z:
|
|
yield y, x
|
|
|
|
|
|
def f():
|
|
for x, y, c in z:
|
|
yield x, y
|
|
|
|
|
|
def f():
|
|
for x in z:
|
|
x = 22
|
|
yield x
|
|
|
|
|
|
def f():
|
|
for x in z:
|
|
yield x
|
|
else:
|
|
print("boom!")
|
|
|
|
|
|
def f():
|
|
for x in range(5):
|
|
yield x
|
|
print(x)
|
|
|
|
|
|
def f():
|
|
def g():
|
|
print(x)
|
|
|
|
for x in range(5):
|
|
yield x
|
|
g()
|
|
|
|
|
|
def f():
|
|
def g():
|
|
def h():
|
|
print(x)
|
|
|
|
return h
|
|
|
|
for x in range(5):
|
|
yield x
|
|
g()()
|
|
|
|
|
|
def f(x):
|
|
for x in y:
|
|
yield x
|
|
del x
|
|
|
|
|
|
async def f():
|
|
for x in y:
|
|
yield x
|
|
|
|
|
|
def f():
|
|
x = 1
|
|
print(x)
|
|
for x in y:
|
|
yield x
|
|
|
|
|
|
def f():
|
|
for x in y:
|
|
yield x
|
|
print(x)
|
|
|
|
|
|
def f():
|
|
for x in y:
|
|
yield x
|
|
z = lambda: x
|
|
|
|
|
|
def f():
|
|
for x in y:
|
|
yield x
|
|
|
|
class C:
|
|
def __init__(self):
|
|
print(x)
|
|
|
|
|
|
def f():
|
|
for x in y:
|
|
yield x, x + 1
|
|
|
|
|
|
def f():
|
|
for x, y in z:
|
|
yield x, y, x + y
|
|
|
|
|
|
def f():
|
|
global some_global
|
|
|
|
for element in iterable:
|
|
some_global = element
|
|
yield some_global
|
|
|
|
|
|
def f():
|
|
some_nonlocal = 1
|
|
|
|
def g():
|
|
nonlocal some_nonlocal
|
|
|
|
for element in iterable:
|
|
some_nonlocal = element
|
|
yield some_nonlocal
|