问题描述
请参阅下面的一个愚蠢的例子来说明我的问题:
class Base():
def info(self,name,age=None,height=None,**kwargs):
print(f"Hi {name},you are {age} years old and {height} cm")
class Derived(Base):
def info(self,**kwargs):
print(super().info(name,**kwargs))
基本上,我想从子类中使用受限制的参数调用父类中的方法。我不希望在子类中指定age
和height
。
我偶然发现了这个答案:https://stackoverflow.com/a/54155637/5859885,所以我在答案中指定的功能中添加了**kwargs
。
但是,我不断收到pylint警告:Unused argument 'kwargs'
和Parameters differ from overridden 'info' method
。
我为什么在这里收到警告?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)