This is the factory method or strategy pattern. These patterns have very good extensibility, like adding new types is straightforward, just create a new class and update the enum. You can find out more about them here: https://realpython.com/factory-method-python/ and https://refactoring.guru/design-patterns/strategy/python/example