module documentation
(source)

Classes for representing mypy types.
Class ​Any​Type The type 'Any'.
Class ​Callable​Argument Represents a Arg(type, 'name') inside a Callable's type list.
Class ​Callable​Type Type of a non-overloaded callable object (such as function).
Class ​Deleted​Type Type of deleted variables.
Class ​Ellipsis​Type The type ... (ellipsis).
Class ​Erased​Type Placeholder for an erased type.
Class ​Function​Like Abstract base class for function types.
Class ​Has​Type​Vars Undocumented
Class ​Instance An instance type of form C[T1, ..., Tn].
Class ​Instantiate​Alias​Visitor Undocumented
Class ​Literal​Type The type of a Literal instance. Literal[Value]
Class ​None​Type The type of 'None'.
Class ​Overloaded Overloaded function type T1, ... Tn, where each Ti is CallableType.
Class ​Param​Spec​Flavor Undocumented
Class ​Param​Spec​Type Type that refers to a ParamSpec.
Class ​Partial​Type Type such as List[?] where type arguments are unknown, or partial None type.
Class ​Placeholder​Type Temporary, yet-unknown type during semantic analysis.
Class ​Proper​Type Not a type alias.
Class ​Raw​Expression​Type A synthetic type representing some arbitrary expression that does not cleanly translate into a type.
Class ​Required​Type Required[T] or NotRequired[T]. Only usable at top-level of a TypedDict definition.
Class ​Star​Type The star type *type_parameter.
Class ​Tuple​Type The tuple type Tuple[T1, ..., Tn] (at least one type argument).
Class ​Type Abstract base class for all types.
Class ​Type​Alias​Type A type alias to another type.
Class ​Typed​Dict​Type Type of TypedDict object {'k1': v1, ..., 'kn': vn}.
Class ​Type​Guarded​Type Only used by find_isinstance_check() etc.
Class ​Type​List Information about argument types and names [...].
Class ​Type​Of​Any This class describes different types of Any. Each 'Any' can be of only one type at a time.
Class ​Type​Str​Visitor Visitor for pretty-printing types into strings.
Class ​Type​Type For types like Type[User].
Class ​Type​Var​Id Undocumented
Class ​Type​Var​Like​Type Undocumented
Class ​Type​Var​Type Type that refers to a type variable.
Class ​Unbound​Type Instance type that has not been bound during semantic analysis.
Class ​Uninhabited​Type This type has no members.
Class ​Union​Type The union type Union[T1, ..., Tn] (at least one type argument).
Class ​Unroll​Alias​Visitor Undocumented
Function callable​_with​_ellipsis Construct type Callable[..., ret_type].
Function copy​_type Build a copy of the type; used to mutate the copy with truthiness information
Function deserialize​_type Undocumented
Function flatten​_nested​_unions Flatten nested unions in a type list.
Function get​_proper​_type Get the expansion of a type alias type.
Function get​_proper​_types Undocumented
Function has​_type​_vars Check if a type contains any type variables (recursively).
Function is​_generic​_instance Undocumented
Function is​_literal​_type Check if this type is a LiteralType with the given fallback type and value.
Function is​_named​_instance Undocumented
Function is​_optional Undocumented
Function is​_union​_with​_any Is this a union with Any or a plain Any type?
Function remove​_optional Undocumented
Function replace​_alias​_tvars Replace type variables in a generic type alias tp with substitutions subs resetting context. Length of subs should be already checked.
Function strip​_type Make a copy of type without 'debugging info' (function name).
Function union​_items Return the flattened items of a union type.
Constant deserialize​_map Undocumented
Constant names Undocumented
Constant NOT​_READY Undocumented
Constant T Undocumented
Constant TP Undocumented
Constant TPDICT​_FB​_NAMES Undocumented
Constant TPDICT​_NAMES Undocumented
Variable ​Formal​Argument Undocumented
Variable ​Json​Dict Undocumented
Variable ​Literal​Value Undocumented
Constant _dummy Undocumented
def callable_with_ellipsis(any_type, ret_type, fallback): (source)
Construct type Callable[..., ret_type].
Parameters
any​_type:AnyTypeUndocumented
ret​_type:TypeUndocumented
fallback:InstanceUndocumented
Returns
CallableTypeUndocumented
def copy_type(t): (source)
Build a copy of the type; used to mutate the copy with truthiness information
Parameters
t:TPUndocumented
Returns
TPUndocumented
def deserialize_type(data): (source)

Undocumented

Parameters
data:Union[JsonDict, str]Undocumented
Returns
TypeUndocumented
def flatten_nested_unions(types, handle_type_alias_type=False): (source)
Flatten nested unions in a type list.
Parameters
types:Iterable[Type]Undocumented
handle​_type​_alias​_type:boolUndocumented
Returns
List[Type]Undocumented
def get_proper_type(typ): (source)

Get the expansion of a type alias type.

If the type is already a proper type, this is a no-op. Use this function wherever a decision is made on a call like e.g. 'if isinstance(typ, UnionType): ...', because 'typ' in this case may be an alias to union. Note: if after making the decision on the isinstance() call you pass on the original type (and not one of its components) it is recommended to always pass on the unexpanded alias.

Parameters
typ:Optional[Type]Undocumented
Returns
Optional[ProperType]Undocumented
def get_proper_types(it): (source)

Undocumented

Parameters
it:Iterable[Optional[Type]]Undocumented
Returns
Union[List[ProperType], List[Optional[ProperType]]]Undocumented
def has_type_vars(typ): (source)
Check if a type contains any type variables (recursively).
Parameters
typ:TypeUndocumented
Returns
boolUndocumented
def is_generic_instance(tp): (source)

Undocumented

Parameters
tp:TypeUndocumented
Returns
boolUndocumented
def is_literal_type(typ, fallback_fullname, value): (source)
Check if this type is a LiteralType with the given fallback type and value.
Parameters
typ:ProperTypeUndocumented
fallback​_fullname:strUndocumented
value:LiteralValueUndocumented
Returns
boolUndocumented
def is_named_instance(t, fullname): (source)

Undocumented

Parameters
t:TypeUndocumented
fullname:strUndocumented
Returns
boolUndocumented
def is_optional(t): (source)

Undocumented

Parameters
t:TypeUndocumented
Returns
boolUndocumented
def is_union_with_any(tp): (source)
Is this a union with Any or a plain Any type?
Parameters
tp:TypeUndocumented
Returns
boolUndocumented
def remove_optional(typ): (source)

Undocumented

Parameters
typ:TypeUndocumented
Returns
TypeUndocumented
def replace_alias_tvars(tp, vars, subs, newline, newcolumn): (source)
Replace type variables in a generic type alias tp with substitutions subs resetting context. Length of subs should be already checked.
Parameters
tp:TypeUndocumented
vars:List[str]Undocumented
subs:List[Type]Undocumented
newline:intUndocumented
newcolumn:intUndocumented
Returns
TypeUndocumented
def strip_type(typ): (source)
Make a copy of type without 'debugging info' (function name).
Parameters
typ:TypeUndocumented
Returns
ProperTypeUndocumented
def union_items(typ): (source)

Return the flattened items of a union type.

For non-union types, return a list containing just the argument.

Parameters
typ:TypeUndocumented
Returns
List[ProperType]Undocumented
deserialize_map = (source)

Undocumented

Value
{key: obj.deserialize for key, obj in names.items() if isinstance(obj, type
    ) and issubclass(obj, Type) and obj is not Type}
names = (source)

Undocumented

Value
globals().copy()
NOT_READY = (source)

Undocumented

Value
mypy.nodes.FakeInfo('De-serialization failure: TypeInfo not fixed')

Undocumented

Value
TypeVar('T')

Undocumented

Value
TypeVar('TP',
        bound=Type)
TPDICT_FB_NAMES: tuple[str, ...] = (source)

Undocumented

Value
('typing._TypedDict',
 'typing_extensions._TypedDict',
 'mypy_extensions._TypedDict')
TPDICT_NAMES: tuple[str, ...] = (source)

Undocumented

Value
('typing.TypedDict', 'typing_extensions.TypedDict', 'mypy_extensions.TypedDict')
FormalArgument = (source)

Undocumented

JsonDict: _TypeAlias = (source)

Undocumented

LiteralValue: _TypeAlias = (source)

Undocumented

_dummy: Any = (source)

Undocumented

Value
object()