from abc import abstractmethod from abc import ABC class Shape(ABC): color = '' @abstractmethod def area(self): pass @abstractmethod def perimetr(self): pass @staticmethod def create_shape(json): if "type" in json: shape_type = json["type"] if shape_type == "circle": return Circle(json("radius")) elif shape_type == "square": return Square(json("side")) elif shape_type == "rectangle": return Rectangle(json["width"], json["height"]) else: raise TypeError(f'Неизвестная фигура {shape_type}')