def strip_type_info(self, info: TypeInfo) -> None: info.type_vars = [] info.bases = [] info.is_abstract = False info.abstract_attributes = [] info.mro = [] info.add_type_vars() info.tuple_type = None info.typeddict_type = None info.tuple_type = None TypeState.reset_subtype_caches_for(info) info.declared_metaclass = None info.metaclass_type = None
def strip_type_info(self, info: TypeInfo) -> None: info.type_vars = [] info.bases = [] info.abstract_attributes = [] info.mro = [] info.add_type_vars() info.tuple_type = None info.typeddict_type = None info.tuple_type = None info._cache = set() info._cache_proper = set() info.declared_metaclass = None info.metaclass_type = None
def create_dynamic_class( ctx: DynamicClassDefContext, bases: List[Instance], *, name: Optional[str] = None, metaclass: Optional[str] = None, symbol_table: Optional[SymbolTable] = None, ) -> TypeInfo: if name is None: name = ctx.name class_def = ClassDef(name, Block([])) class_def.fullname = ctx.api.qualified_name(ctx.name) info = TypeInfo(SymbolTable(), class_def, ctx.api.cur_mod_id) if metaclass is not None: metaclass_type_info = lookup_type_info(ctx.api, metaclass) if metaclass_type_info is not None: info.declared_metaclass = Instance(metaclass_type_info, []) class_def.info = info obj = ctx.api.builtin_type("builtins.object") info.bases = bases or [obj] try: calculate_mro(info) except MroError: ctx.api.fail("Not able to calculate MRO for dynamic class", ctx.call) info.bases = [obj] info.fallback_to_any = True if symbol_table is None: ctx.api.add_symbol_table_node(name, SymbolTableNode(GDEF, info)) else: symbol_table[name] = SymbolTableNode(GDEF, info) add_metadata_var(ctx.api, info) add_query_cls_var(ctx.api, info) return info
def strip_type_info(self, info: TypeInfo) -> List[SymbolNode]: info.type_vars = [] info.bases = [] info.is_abstract = False info.abstract_attributes = [] info.mro = [] info.add_type_vars() info.tuple_type = None info.typeddict_type = None info.tuple_type = None TypeState.reset_subtype_caches_for(info) info.declared_metaclass = None info.metaclass_type = None # We need to delete any entries that were generated by plugins, # since they will get regenerated. to_delete = [(k, v) for k, v in info.names.items() if v.plugin_generated] for k, _ in to_delete: del info.names[k] return [v.node for k, v in to_delete if v.node]