[Python-projects] Can we instrauct pylint to allow unused arguments?

Sylvain Thénault Sylvain.Thenault at logilab.fr
Tue Nov 16 09:43:19 CET 2004

On Monday 15 November à 17:26, Pierre_Rouleau at ImpathNetworks.com wrote:
> Hi all,

Hi Pierre,
> When using GUI frameworks like wxPython, you often have to write a large
> collection of event handling call-back methods.
> These methods often have arguments that may not be used (like event in the
> following method).
> def OnAcceptButton(self, event):
>     """Perform fields validation on Enter, close dialog if all data is valid"""
>     self.do_something()
> Is there a way to prevent the "Unused argument" for that special case only.  I
> do not want to disable the warning completely.
> Can I disable it only if the argument is called "event" or whatever or if it
> starts with something like "unused_".
> That would help reducing the warnings in valid wxPython applications.
> Is there another, better way, to acheive the same thing?

You can either :
- prefix your method/function by "cb_" to informe pylint that it's a
  callback and so it shouldn't check for unsused argument
- use names listed in the "dummy-variables" configuration variable ("_"
  and "dummy" by default) as arguments names

Sylvain Thénault                               LOGILAB, Paris (France).

http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org

More information about the Python-Projects mailing list