Skip to content

Commit

Permalink
[ruff] Fix false positive on global keyword (RUF052)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garrett-R committed Jan 3, 2025
1 parent a3d873e commit 70f2f89
Show file tree
Hide file tree
Showing 6 changed files with 583 additions and 569 deletions.
15 changes: 13 additions & 2 deletions crates/ruff_linter/resources/test/fixtures/ruff/RUF052.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Correct
##################### Correct #####################

for _ in range(5):
pass
Expand Down Expand Up @@ -37,6 +37,17 @@ def fun():
_x = "reassigned global"
return _x

# (we had a false positive when a global var is used like this in 2 functions)
_num: int

def set_num():
global _num
_num = 1

def print_num():
print(_num)


class _ValidClass:
pass

Expand Down Expand Up @@ -70,7 +81,7 @@ def fun(x):
return ___
return x

# Incorrect
##################### Incorrect #####################

class Class_:
def fun(self):
Expand Down
Loading

0 comments on commit 70f2f89

Please sign in to comment.