Python3 abstractmethod, parameters differ from overridden method

Viewed 1230

The class Parent has an abstract method and I need to use a different number and types of arguments in the method in the children classes/methods.

from abc import ABC, abstractmethod


class Parent(ABC):
    """Parent"""
    @abstractmethod
    def method(self, *args):
        """method"""


class Child1(Parent):
    """Child1"""
    def method(self, arg1: int):
        print(arg1)


class Child2(Parent):
    """Child2"""
    def method(self, arg1: str, arg2: dict):
        print(arg1, arg2)

For this code pylint is showing me next warning:

[W0221(arguments-differ), Child1.method] Parameters differ from overridden 'method' method

Is it possible to solve the pylint warning and continue using different arguments in children classes? I don't want to use *args in children methods.

0 Answers
Related