class documentation

For types like Type[User]. This annotates variables that are class objects, constrained by the type argument. See PEP 484 for more details. We may encounter expressions whose values are specific classes; those are represented as callables (possibly overloaded) corresponding to the class's constructor's signature and returning an instance of that class. The difference with Type[C] is that those callables always represent the exact class given as the return type; Type[C] represents any class that's a subclass of C, and C may also be a type variable or a union (or Any). Many questions around subtype relationships between Type[C1] and def(...) -> C2 are answered by looking at the subtype relationships between C1 and C2, since Type[] is considered covariant. There's an unsolved problem with constructor signatures (also unsolved in PEP 484): calling a variable whose type is Type[C] assumes the constructor signature for C, even though a subclass of C might completely change the constructor signature. For now we just assume that users of Type[C] are careful not to do that (in the future we might detect when they are violating that assumption).

Class Method deserialize Undocumented
Static Method make_normalized Undocumented
Method __eq__ Undocumented
Method __hash__ Undocumented
Method __init__ To ensure Type[Union[A, B]] is always represented as Union[Type[A], Type[B]], item of type UnionType must be handled through make_normalized static method.
Method accept Undocumented
Method serialize Undocumented
Class Variable __slots__ Undocumented
Instance Variable item Undocumented

Inherited from Type (via ProperType):

Method __repr__ Undocumented
Method can_be_false.setter Undocumented
Method can_be_false_default Undocumented
Method can_be_true.setter Undocumented
Method can_be_true_default Undocumented
Method is_singleton_type Undocumented
Property can_be_false Undocumented
Property can_be_true Undocumented
Instance Variable _can_be_false Undocumented
Instance Variable _can_be_true Undocumented

Inherited from Context (via ProperType, Type):

Method set_line If target is a node, pull line (and column) information into this node. If column is specified, this will override any column information coming from a node.
Instance Variable column Undocumented
Instance Variable end_column Undocumented
Instance Variable end_line Undocumented
Instance Variable line Undocumented
@classmethod
def deserialize(cls, data: JsonDict) -> Type: (source)

Undocumented

@staticmethod
def make_normalized(item: Type, *, line: int = -1, column: int = -1) -> ProperType: (source)

Undocumented

def __eq__(self, other: object) -> bool: (source)

Undocumented

def __hash__(self) -> int: (source)

Undocumented

def __init__(self, item: Bogus[((((Instance|AnyType)|TypeVarType)|TupleType)|NoneType)|CallableType], *, line: int = -1, column: int = -1): (source)

To ensure Type[Union[A, B]] is always represented as Union[Type[A], Type[B]], item of type UnionType must be handled through make_normalized static method.

def accept(self, visitor: TypeVisitor[T]) -> T: (source)

Undocumented

def serialize(self) -> JsonDict: (source)

Undocumented

__slots__: tuple[str, ...] = (source)

Undocumented

Undocumented