File tree 2 files changed +15
-0
lines changed
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(
1222
1222
if new_frame is None :
1223
1223
new_frame = self .binder .push_frame ()
1224
1224
new_frame .types [key ] = narrowed_type
1225
+ self .binder .declarations [key ] = old_binder .declarations [key ]
1225
1226
with self .scope .push_function (defn ):
1226
1227
# We suppress reachability warnings when we use TypeVars with value
1227
1228
# 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:
1329
1329
y, x = None, None
1330
1330
1331
1331
[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