问题描述
Parent 类有一个抽象方法,我需要在子类/方法的方法中使用不同数量和类型的参数。
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)
[W0221(arguments-difer),Child1.method] 参数不同于 重写的“方法”方法
是否可以解决 pylint 警告并继续在子类中使用不同的参数?
我不想在子方法中使用 *args
。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)