@@ -900,13 +900,7 @@ def visit_class_def(self, o: ClassDef) -> None:
900900 if isinstance (o .metaclass , (NameExpr , MemberExpr )):
901901 meta = o .metaclass .accept (AliasPrinter (self ))
902902 base_types .append ("metaclass=" + meta )
903- elif self .analyzed and o .info .is_protocol :
904- type_str = "Protocol"
905- if o .info .type_vars :
906- type_str += f'[{ ", " .join (o .info .type_vars )} ]'
907- base_types .append (type_str )
908- self .add_typing_import ("Protocol" )
909- elif self .analyzed and o .info .is_abstract :
903+ elif self .analyzed and o .info .is_abstract and not o .info .is_protocol :
910904 base_types .append ("metaclass=abc.ABCMeta" )
911905 self .import_tracker .add_import ("abc" )
912906 self .import_tracker .require_name ("abc" )
@@ -933,7 +927,7 @@ def get_base_types(self, cdef: ClassDef) -> list[str]:
933927 """Get list of base classes for a class."""
934928 base_types : list [str ] = []
935929 p = AliasPrinter (self )
936- for base in cdef .base_type_exprs :
930+ for base in cdef .base_type_exprs + cdef . removed_base_type_exprs :
937931 if isinstance (base , (NameExpr , MemberExpr )):
938932 if self .get_fullname (base ) != "builtins.object" :
939933 base_types .append (get_qualified_name (base ))
0 commit comments