class documentation

class TypeInfo(SymbolNode): (source)

Known subclasses: mypy.nodes.FakeInfo

View In Hierarchy

The type structure of a single class.

Each TypeInfo corresponds one-to-one to a ClassDef, which represents the AST of the class.

In type-theory terms, this is a "type constructor", and if the class is generic then it will be a type constructor of higher kind. Where the class is used in an actual type, it's in the form of an Instance, which amounts to a type application of the tycon to the appropriate number of arguments.

Class Method deserialize Undocumented
Method __bool__ Undocumented
Method __getitem__ Undocumented
Method __init__ Initialize a TypeInfo.
Method __repr__ Undocumented
Method __str__ Return a string representation of the type.
Method add​_type​_vars Undocumented
Method calculate​_metaclass​_type Undocumented
Method direct​_base​_classes Return a direct base classes.
Method dump Return a string dump of the contents of the TypeInfo.
Method get Undocumented
Method get​_containing​_type​_info Undocumented
Method get​_method Undocumented
Method has​_base Return True if type has a base type with the specified name.
Method has​_readable​_member Undocumented
Method is​_generic Is the type generic (i.e. does it have type variables)?
Method is​_metaclass Undocumented
Method serialize Undocumented
Constant FLAGS Undocumented
Class Variable __slots__ Undocumented
Instance Variable abstract​_attributes Undocumented
Instance Variable assuming Undocumented
Instance Variable assuming​_proper Undocumented
Instance Variable bad​_mro Undocumented
Instance Variable bases Undocumented
Instance Variable declared​_metaclass Undocumented
Instance Variable defn Undocumented
Instance Variable deletable​_attributes Undocumented
Instance Variable fallback​_to​_any Undocumented
Instance Variable inferring Undocumented
Instance Variable is​_abstract Undocumented
Instance Variable is​_enum Undocumented
Instance Variable is​_final Undocumented
Instance Variable is​_intersection Undocumented
Instance Variable is​_named​_tuple Undocumented
Instance Variable is​_newtype Undocumented
Instance Variable is​_protocol Undocumented
Instance Variable metaclass​_type Undocumented
Instance Variable metadata Undocumented
Instance Variable module​_name Undocumented
Instance Variable mro Undocumented
Instance Variable names Undocumented
Instance Variable runtime​_protocol Undocumented
Instance Variable slots Undocumented
Instance Variable tuple​_type Undocumented
Instance Variable type​_vars Undocumented
Instance Variable typeddict​_type Undocumented
Property fullname Undocumented
Property name Short name.
Property protocol​_members Undocumented
Instance Variable _fullname Undocumented
Instance Variable _mro​_refs Undocumented
Instance Variable _promote Undocumented

Inherited from Node (via SymbolNode):

Method accept Undocumented

Inherited from Context (via SymbolNode, Node):

Method get​_column Don't use. Use x.column.
Method get​_line Don't use. Use x.line.
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​_line Undocumented
Instance Variable line Undocumented
@classmethod
def deserialize(cls, data): (source)

Undocumented

Parameters
data:JsonDictUndocumented
Returns
TypeInfoUndocumented
def __bool__(self): (source)

Undocumented

Returns
boolUndocumented
def __getitem__(self, name): (source)

Undocumented

Parameters
name:strUndocumented
Returns
SymbolTableNodeUndocumented
def __init__(self, names, defn, module_name): (source)
overridden in mypy.nodes.FakeInfo
Initialize a TypeInfo.
Parameters
names:SymbolTableUndocumented
defn:ClassDefUndocumented
module​_name:strUndocumented
def __repr__(self): (source)

Undocumented

Returns
strUndocumented
def __str__(self): (source)

Return a string representation of the type.

This includes the most important information about the type.

Returns
strUndocumented
def add_type_vars(self): (source)

Undocumented

def calculate_metaclass_type(self): (source)

Undocumented

Returns
Optional[mypy.types.Instance]Undocumented
def direct_base_classes(self): (source)

Return a direct base classes.

Omit base classes of other base classes.

Returns
List[TypeInfo]Undocumented
def dump(self, str_conv=None, type_str_conv=None): (source)
Return a string dump of the contents of the TypeInfo.
Parameters
str​_conv:Optional[mypy.strconv.StrConv]Undocumented
type​_str​_conv:Optional[mypy.types.TypeStrVisitor]Undocumented
Returns
strUndocumented
def get(self, name): (source)

Undocumented

Parameters
name:strUndocumented
Returns
Optional[SymbolTableNode]Undocumented
def get_containing_type_info(self, name): (source)

Undocumented

Parameters
name:strUndocumented
Returns
Optional[TypeInfo]Undocumented
def get_method(self, name): (source)

Undocumented

Parameters
name:strUndocumented
Returns
Union[FuncBase, Decorator, None]Undocumented
def has_base(self, fullname): (source)

Return True if type has a base type with the specified name.

This can be either via extension or via implementation.

Parameters
fullname:strUndocumented
Returns
boolUndocumented
def has_readable_member(self, name): (source)

Undocumented

Parameters
name:strUndocumented
Returns
boolUndocumented
def is_generic(self): (source)
Is the type generic (i.e. does it have type variables)?
Returns
boolUndocumented
def is_metaclass(self): (source)

Undocumented

Returns
boolUndocumented
def serialize(self): (source)

Undocumented

Returns
JsonDictUndocumented
FLAGS: list[str] = (source)

Undocumented

Value
['is_abstract',
 'is_enum',
 'fallback_to_any',
 'is_named_tuple',
 'is_newtype',
 'is_protocol',
 'runtime_protocol',
...
__slots__: tuple[str, ...] = (source)
overridden in mypy.nodes.FakeInfo

Undocumented

abstract_attributes: list = (source)

Undocumented

assuming: list = (source)

Undocumented

assuming_proper: list = (source)

Undocumented

bad_mro: bool = (source)

Undocumented

bases: list = (source)

Undocumented

declared_metaclass = (source)

Undocumented

defn = (source)

Undocumented

deletable_attributes: list = (source)

Undocumented

fallback_to_any: bool = (source)

Undocumented

inferring: list = (source)

Undocumented

is_abstract: bool = (source)

Undocumented

is_enum: bool = (source)

Undocumented

is_final: bool = (source)

Undocumented

is_intersection: bool = (source)

Undocumented

is_named_tuple: bool = (source)

Undocumented

is_newtype: bool = (source)

Undocumented

is_protocol: bool = (source)

Undocumented

metaclass_type = (source)

Undocumented

metadata: dict = (source)

Undocumented

module_name = (source)

Undocumented

mro: list = (source)

Undocumented

names = (source)

Undocumented

runtime_protocol: bool = (source)

Undocumented

slots = (source)

Undocumented

tuple_type = (source)

Undocumented

type_vars: list = (source)

Undocumented

typeddict_type = (source)

Undocumented

@property
fullname: Bogus[str] = (source)

Undocumented

@property
name: str = (source)
Short name.
@property
protocol_members: List[str] = (source)

Undocumented

_fullname = (source)

Undocumented

_mro_refs = (source)

Undocumented

_promote = (source)

Undocumented