Files
ruff/crates/red_knot_python_semantic/resources/mdtest/assignment/unbound.md
Alex d77480768d [red-knot] Port type inference tests to new test framework (#13719)
## Summary

Porting infer tests to new markdown tests framework.

Link to the corresponding issue: #13696

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2024-10-15 11:23:46 -07:00

460 B

Unbound

Maybe unbound

if flag:
    y = 3
x = y
reveal_type(x)  # revealed: Unbound | Literal[3]

Unbound

x = foo; foo = 1
reveal_type(x)  # revealed: Unbound

Unbound class variable

Class variables can reference global variables unless overridden within the class scope.

x = 1
class C:
    y = x
    if flag:
        x = 2

reveal_type(C.x) # revealed: Unbound | Literal[2]
reveal_type(C.y) # revealed: Literal[1]