File tree Expand file tree Collapse file tree
crates/red_knot_python_semantic
resources/mdtest/annotations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,3 +69,15 @@ y: int = Subclass() # error: [invalid-assignment]
6969def _ (s : Subclass):
7070 reveal_type(s) # revealed: Subclass
7171```
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> {
48634863 }
48644864 KnownInstanceType :: Type => self . infer_subclass_of_type_expression ( parameters) ,
48654865 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+ }
48674877 }
48684878 }
48694879
You can’t perform that action at this time.
0 commit comments