I have an abstract class written in Python:
class AbsctracClass(ABC):
@abstractmethod
def method(self,
value1: int,
value2: float,
value3: str,
value4: Optional[list] = None,
value5: Optional[int] = None,
value6: Optional[float] = None,
... etc ...,
):
''' An abstract method for an abstract class '''
It has one abstract method with a lot of arguments. I know, I know, it is not a good practice to pass lots of arguments to a function, but right now it's irrelevant for my question.
Now I want to write another class that inherits from AbstractClass. And I have to manually duplicate all the arguments with their type hints from an abstract class.
class AnotherClass(AbstractClass):
def method(self,
value1: int,
value2: float,
value3: str,
value4: Optional[list] = None,
value5: Optional[int] = None,
value6: Optional[float] = None,
... etc ...,
):
return value3 * (value2 + value3)
It is not only cumbersome when I have several abstract methods and several classes inherits from it, but pylint
screams about code duplication. And, to be honest, I agree with him.
Obviously there must be a better way. Is it?