File tree 2 files changed +23
-1
lines changed
crates/red_knot_python_semantic
resources/mdtest/annotations
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -69,3 +69,15 @@ y: int = Subclass() # error: [invalid-assignment]
69
69
def _ (s : Subclass):
70
70
reveal_type(s) # revealed: Subclass
71
71
```
72
+
73
+ ## Invalid
74
+
75
+ ` Any ` cannot be parameterized:
76
+
77
+ ``` py
78
+ from typing import Any
79
+
80
+ # error: [invalid-type-parameter] "Type `typing.Any` expected no type parameter"
81
+ def f (x : Any[int ]):
82
+ reveal_type(x) # revealed: Unknown
83
+ ```
Original file line number Diff line number Diff line change @@ -4863,7 +4863,17 @@ impl<'db> TypeInferenceBuilder<'db> {
4863
4863
}
4864
4864
KnownInstanceType :: Type => self . infer_subclass_of_type_expression ( parameters) ,
4865
4865
KnownInstanceType :: Tuple => self . infer_tuple_type_expression ( parameters) ,
4866
- KnownInstanceType :: Any => Type :: Any ,
4866
+ KnownInstanceType :: Any => {
4867
+ self . diagnostics . add_lint (
4868
+ & INVALID_TYPE_PARAMETER ,
4869
+ subscript. into ( ) ,
4870
+ format_args ! (
4871
+ "Type `{}` expected no type parameter" ,
4872
+ known_instance. repr( self . db)
4873
+ ) ,
4874
+ ) ;
4875
+ Type :: Unknown
4876
+ }
4867
4877
}
4868
4878
}
4869
4879
You can’t perform that action at this time.
0 commit comments