Abstract classes with varying amounts of parameters
No checks are done on how many arguments concrete implementations take. So there is nothing stopping your from doing this already.
Just define those methods to take whatever parameters you need to accept:
class View(metaclass=ABCMeta): @abstractmethod def set(self): pass @abstractmethod def get(self): passclass ConcreteView1(View): def set(self, param1): # implemenation def get(self, param1, param2): # implemenationclass ConcreteView2(View): def set(self): # implemenation def get(self, param1, param2): # implemenation
python 3.8
from abc import ABC, abstractmethodclass SomeAbstractClass(ABC): @abstractmethod def get(self, *args, **kwargs): """ Returns smth """ @abstractmethod def set(self, key, value): """ Sets smth """class Implementation(SomeAbstractClass): def set(self, key, value): pass def get(self, some_var, another_one): pass
Works perfectly, no warnings, no problems