File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1222,6 +1222,7 @@ def check_func_def(
12221222 if new_frame is None :
12231223 new_frame = self .binder .push_frame ()
12241224 new_frame .types [key ] = narrowed_type
1225+ self .binder .declarations [key ] = old_binder .declarations [key ]
12251226 with self .scope .push_function (defn ):
12261227 # We suppress reachability warnings when we use TypeVars with value
12271228 # restrictions: we only want to report a warning if a certain statement is
Original file line number Diff line number Diff line change @@ -1329,3 +1329,17 @@ def narrow_with_multi_assign_3(x: Optional[str]) -> None:
13291329 y, x = None, None
13301330
13311331[builtins fixtures/isinstance.pyi]
1332+
1333+ [case testNestedFunctionSpecialCase]
1334+ class C:
1335+ def __enter__(self, *args): ...
1336+ def __exit__(self, *args) -> bool: ...
1337+
1338+ def f(x: object) -> None:
1339+ if x is not None:
1340+ pass
1341+
1342+ def nested() -> None:
1343+ with C():
1344+ pass
1345+ [builtins fixtures/tuple.pyi]
You can’t perform that action at this time.
0 commit comments