File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1110,6 +1110,7 @@ def check_func_item(
11101110 """
11111111 self .dynamic_funcs .append (defn .is_dynamic () and not type_override )
11121112
1113+ enclosing_node_deferred = self .current_node_deferred
11131114 with self .enter_partial_types (is_function = True ):
11141115 typ = self .function_type (defn )
11151116 if type_override :
@@ -1121,7 +1122,7 @@ def check_func_item(
11211122 raise RuntimeError ("Not supported" )
11221123
11231124 self .dynamic_funcs .pop ()
1124- self .current_node_deferred = False
1125+ self .current_node_deferred = enclosing_node_deferred
11251126
11261127 if name == "__exit__" :
11271128 self .check__exit__return_type (defn )
Original file line number Diff line number Diff line change @@ -3913,3 +3913,21 @@ x = "abc"
39133913for x in list[int]():
39143914 reveal_type(x) # N: Revealed type is "builtins.int"
39153915reveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str]"
3916+
3917+ [case testVariableDeferredWithNestedFunction]
3918+ from typing import Callable, TypeVar
3919+
3920+ T = TypeVar("T")
3921+ def deco(fn: Callable[[], T]) -> Callable[[], T]: ...
3922+
3923+ @deco
3924+ def f() -> None:
3925+ x = 1
3926+ f() # defer current node
3927+ x = x
3928+
3929+ def nested() -> None:
3930+ ...
3931+
3932+ # The type below should not be Any.
3933+ reveal_type(x) # N: Revealed type is "builtins.int"
You can’t perform that action at this time.
0 commit comments