mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
760 B
760 B
Nonlocal references
One level up
def f():
x = 1
def g():
reveal_type(x) # revealed: Unknown | Literal[1]
Two levels up
def f():
x = 1
def g():
def h():
reveal_type(x) # revealed: Unknown | Literal[1]
Skips class scope
def f():
x = 1
class C:
x = 2
def g():
reveal_type(x) # revealed: Unknown | Literal[1]
Skips annotation-only assignment
def f():
x = 1
def g():
# it's pretty weird to have an annotated assignment in a function where the
# name is otherwise not defined; maybe should be an error?
x: int
def h():
reveal_type(x) # revealed: Unknown | Literal[1]