2

See below for a silly example to illustrate my problem:

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, name, **kwargs):
      print(super().info(name, **kwargs))

Essentially, I want to call the method in the parent class from the child class with restricted arguments. I don't want age and height to be specified in the child class.

I stumbled upon this answer: https://stackoverflow.com/a/54155637/5859885, so I added the **kwargs in to the functions as specified in the answer.

But, I keep getting pylint warnings: Unused argument 'kwargs' and Parameters differ from overridden 'info' method.

Why am I getting warnings here?

the man
  • 1,131
  • 1
  • 8
  • 19
  • Why does *`Base.info`* take `**kwargs`…!? – deceze Aug 26 '20 at 12:24
  • @deceze Why does the linked answer take ```**kwargs```? I was just trying to get rid of pylint's ```Parameters differ from overridden 'info' method``` warning and stumbled across that answer – the man Aug 26 '20 at 12:32
  • 2
    Well, don't copy something without understanding it. It makes sense for `Derived.info` to accept `**kwargs` and pass them to the parent. But it doesn't make sense for `Base.info` to accept `**kwargs` it doesn't use. – deceze Aug 26 '20 at 12:36
  • Came here for the answer on derived methods with unused argument warnings in PyLint. Did you figure it out? – dKen Apr 01 '22 at 05:08

0 Answers0