We have an internal representation (Type::Any) for the dynamic type Any, but we don't yet understand the typing.Any symbol as a spelling for that type in a type expression.
To add this, we'll need to track typing.Any as a KnownInstance (similar to the existing support for typing.Union, typing.Optional, typing.Literal), and add support for it in Type::in_type_expression, so that when TypeInferenceBuilder::infer_type_expression comes across the symbol in an annotation, we understand that annotation as describing the Any type.
We'll want to add mdtests for the "happy path" case like this:
x: Any = 1
x = "foo"
def f():
reveal_type(x) # revealed: Any
We'll also want edge-case tests showing that typing.Any can be aliased to a different name, and still works (that is, we are recognizing typing.Any under any name, not just pattern-matching on the local name), and similarly that a locally-defined class named Any simply means its own instance type, not Type::Any, in an annotation.
We have an internal representation (
Type::Any) for the dynamic typeAny, but we don't yet understand thetyping.Anysymbol as a spelling for that type in a type expression.To add this, we'll need to track
typing.Anyas aKnownInstance(similar to the existing support fortyping.Union,typing.Optional,typing.Literal), and add support for it inType::in_type_expression, so that whenTypeInferenceBuilder::infer_type_expressioncomes across the symbol in an annotation, we understand that annotation as describing theAnytype.We'll want to add mdtests for the "happy path" case like this:
We'll also want edge-case tests showing that
typing.Anycan be aliased to a different name, and still works (that is, we are recognizingtyping.Anyunder any name, not just pattern-matching on the local name), and similarly that a locally-defined class namedAnysimply means its own instance type, notType::Any, in an annotation.