File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -5502,7 +5502,7 @@ def visit_with_stmt(self, s: WithStmt) -> None:
55025502 self .accept (s .body )
55035503
55045504 def check_untyped_after_decorator (self , typ : Type , func : FuncDef ) -> None :
5505- if not self .options .disallow_any_decorated or self .is_stub :
5505+ if not self .options .disallow_any_decorated or self .is_stub or self . current_node_deferred :
55065506 return
55075507
55085508 if mypy .checkexpr .has_any_type (typ ):
Original file line number Diff line number Diff line change @@ -1116,6 +1116,39 @@ def f(x: Any) -> Any: # E: Function is untyped after decorator transformation
11161116def h(x): # E: Function is untyped after decorator transformation
11171117 pass
11181118[builtins fixtures/list.pyi]
1119+
1120+ [case testDisallowAnyDecoratedUnannotatedDecoratorDeferred1]
1121+ # flags: --disallow-any-decorated
1122+ from typing import Callable
1123+
1124+ def d(f: Callable[[int], None]) -> Callable[[int], None]:
1125+ return f
1126+
1127+ def wrapper() -> None:
1128+ if c:
1129+ @d
1130+ def h(x):
1131+ pass
1132+
1133+ c = [1]
1134+ [builtins fixtures/list.pyi]
1135+
1136+ [case testDisallowAnyDecoratedUnannotatedDecoratorDeferred2]
1137+ # flags: --disallow-any-decorated
1138+ from typing import Callable
1139+
1140+ def d(f: Callable[[int], None]) -> Callable[[int], None]:
1141+ return f
1142+
1143+ c = 1 # no deferral - check that the previous testcase is valid
1144+
1145+ def wrapper() -> None:
1146+ if c:
1147+ @d
1148+ def h(x):
1149+ pass
1150+ [builtins fixtures/list.pyi]
1151+
11191152[case testDisallowAnyDecoratedErrorIsReportedOnlyOnce]
11201153# flags: --disallow-any-decorated
11211154
You can’t perform that action at this time.
0 commit comments