module documentation

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
def add_type_promotion(info: TypeInfo, module_names: SymbolTable, options: Options, builtin_names: SymbolTable): (source)

Setup extra, ad-hoc subtyping relationships between classes (promotion). This includes things like 'int' being compatible with 'float'.

def calculate_class_abstract_status(typ: TypeInfo, is_stub_file: bool, errors: 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.

def calculate_class_vars(info: TypeInfo): (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.

def check_protocol_status(info: TypeInfo, errors: Errors): (source)

Check that all classes in MRO of a protocol are protocols

TYPE_PROMOTIONS: dict[str, str] = (source)

Undocumented

Value
{'builtins.int': 'float',
 'builtins.float': 'complex',
 'builtins.bytearray': 'bytes',
 'builtins.memoryview': 'bytes'}