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:
5502
5502
self .accept (s .body )
5503
5503
5504
5504
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 :
5506
5506
return
5507
5507
5508
5508
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
1116
1116
def h(x): # E: Function is untyped after decorator transformation
1117
1117
pass
1118
1118
[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
+
1119
1152
[case testDisallowAnyDecoratedErrorIsReportedOnlyOnce]
1120
1153
# flags: --disallow-any-decorated
1121
1154
You can’t perform that action at this time.
0 commit comments