[Python-projects] pylint: Do not warn about unused arguments on function that always raises?

Sylvain Thénault sylvain.thenault at logilab.fr
Thu Mar 26 08:35:07 CET 2009


Le Thursday 26 March 2009 00:34:17 Maarten ter Huurne, vous avez écrit :
> Hi,
>
> Please consider the following code:
>
> ===
> try:
> 	from os import symlink
> except ImportError:
> 	def symlink(src, dst):
> 		raise OSError('This platform does not support symbolic links')
> print symlink
> ===
> W0613:  4:symlink: Unused argument 'src'
> W0613:  4:symlink: Unused argument 'dst'
>
> pylint is correct that the arguments are not used. They cannot be omitted
> though because the replacement symlink function must have the same
> signature as the one that could not be imported.
>
> Would it make sense to ignore non-use of arguments on functions that
> unconditionally raise an exception? Or is this case too specific and would
> that approach cause false negatives in practice?

dunno. Iirc, we do such thing for functions / methods which are simply raising 
NotImplementedError. Is this an option in your code? or do you have some 
examples in mind where it would make sense?

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
Python et calcul scientifique:           http://www.logilab.fr/science


More information about the Python-Projects mailing list