mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-25 06:13:01 +00:00
[ty] name is parameter and global is a syntax error (#21312)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com> Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
This commit is contained in:
parent
8599c7e5b3
commit
8529d79a70
6 changed files with 194 additions and 18 deletions
|
|
@ -376,3 +376,41 @@ for x in range(42):
|
|||
break # error: [invalid-syntax]
|
||||
continue # error: [invalid-syntax]
|
||||
```
|
||||
|
||||
## name is parameter and global
|
||||
|
||||
<!-- snapshot-diagnostics -->
|
||||
|
||||
```py
|
||||
a = None
|
||||
|
||||
def f(a):
|
||||
global a # error: [invalid-syntax]
|
||||
|
||||
def g(a):
|
||||
if True:
|
||||
global a # error: [invalid-syntax]
|
||||
|
||||
def h(a):
|
||||
def inner():
|
||||
global a
|
||||
|
||||
def i(a):
|
||||
try:
|
||||
global a # error: [invalid-syntax]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def f(a):
|
||||
a = 1
|
||||
global a # error: [invalid-syntax]
|
||||
|
||||
def f(a):
|
||||
a = 1
|
||||
a = 2
|
||||
global a # error: [invalid-syntax]
|
||||
|
||||
def f(a):
|
||||
class Inner:
|
||||
global a # ok
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue