module documentation
(source)

Calculate some properties of classes.

These happen after semantic analysis and before type checking.

Function add​_type​_promotion Setup extra, ad-hoc subtyping relationships between classes (promotion).
Function calculate​_class​_abstract​_status Calculate abstract status of a class.
Function calculate​_class​_vars Try to infer additional class variables.
Function check​_protocol​_status Check that all classes in MRO of a protocol are protocols
Constant TYPE​_PROMOTIONS Undocumented
Constant TYPE​_PROMOTIONS​_PYTHON2 Undocumented
Constant TYPE​_PROMOTIONS​_PYTHON3 Undocumented
def add_type_promotion(info, module_names, options): (source)

Setup extra, ad-hoc subtyping relationships between classes (promotion).

This includes things like 'int' being compatible with 'float'.

Parameters
info:TypeInfoUndocumented
module​_names:SymbolTableUndocumented
options:OptionsUndocumented
def calculate_class_abstract_status(typ, is_stub_file, errors): (source)

Calculate abstract status of a class.

Set is_abstract of the type to True if the type has an unimplemented abstract attribute. Also compute a list of abstract attributes. Report error is required ABCMeta metaclass is missing.

Parameters
typ:TypeInfoUndocumented
is​_stub​_file:boolUndocumented
errors:ErrorsUndocumented
def calculate_class_vars(info): (source)

Try to infer additional class variables.

Subclass attribute assignments with no type annotation are assumed to be classvar if overriding a declared classvar from the base class.

This must happen after the main semantic analysis pass, since this depends on base class bodies having been fully analyzed.

Parameters
info:TypeInfoUndocumented
def check_protocol_status(info, errors): (source)
Check that all classes in MRO of a protocol are protocols
Parameters
info:TypeInfoUndocumented
errors:ErrorsUndocumented
TYPE_PROMOTIONS: dict[str, str] = (source)

Undocumented

Value
{'builtins.int': 'float', 'builtins.float': 'complex'}
TYPE_PROMOTIONS_PYTHON2 = (source)

Undocumented

Value
TYPE_PROMOTIONS.copy()
TYPE_PROMOTIONS_PYTHON3 = (source)

Undocumented

Value
TYPE_PROMOTIONS.copy()