mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-15 22:14:44 +00:00
[ty] improve lazy scope place lookup (#19321)
Co-authored-by: David Peter <sharkdp@users.noreply.github.com> Co-authored-by: Carl Meyer <carl@oddbird.net> Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
57373a7e4d
commit
b124e182ca
15 changed files with 493 additions and 179 deletions
|
|
@ -806,11 +806,7 @@ def top_level_return(cond1: bool, cond2: bool):
|
|||
x = 1
|
||||
|
||||
def g():
|
||||
# TODO We could potentially eliminate `Unknown` from the union here,
|
||||
# because `x` resolves to an enclosing function-like scope and there
|
||||
# are no nested `nonlocal` declarations of that symbol that might
|
||||
# modify it.
|
||||
reveal_type(x) # revealed: Unknown | Literal[1, 2, 3]
|
||||
reveal_type(x) # revealed: Literal[1, 2, 3]
|
||||
if cond1:
|
||||
if cond2:
|
||||
x = 2
|
||||
|
|
@ -822,7 +818,7 @@ def return_from_if(cond1: bool, cond2: bool):
|
|||
x = 1
|
||||
|
||||
def g():
|
||||
reveal_type(x) # revealed: Unknown | Literal[1, 2, 3]
|
||||
reveal_type(x) # revealed: Literal[1, 2, 3]
|
||||
if cond1:
|
||||
if cond2:
|
||||
x = 2
|
||||
|
|
@ -834,7 +830,7 @@ def return_from_nested_if(cond1: bool, cond2: bool):
|
|||
x = 1
|
||||
|
||||
def g():
|
||||
reveal_type(x) # revealed: Unknown | Literal[1, 2, 3]
|
||||
reveal_type(x) # revealed: Literal[1, 2, 3]
|
||||
if cond1:
|
||||
if cond2:
|
||||
x = 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue