[Python-projects] pylint W0142 recommended corrections
Amaury Forgeot d'Arc
amauryfa at gmail.com
Fri Jul 13 13:29:23 CEST 2007
Hello Sylvain,
Sylvain Thénault wrote:
> On Wednesday 11 July à 09:57, Gurganus, Brant L wrote:
> > I am working on some Python code where Pylint gives a warning of:
> > W: 31:ProxyFactory._init_instance: Used * or ** magic
> >
> > The basic code is:
> > def _init_instance(self, *args, **kwargs):
> > self.__class__._original.__dict__["__init__"](self, *args, **kwargs)
> >
> > The only other method in my mind for doing this would be to use apply, but the
> > *args, **kwargs method appears to be favored over apply right now.
> >
> > Is there a recommended way to correct this or is this a case where silencing
> > the warning is a better solution?
>
> well, pylint flag * or ** usage to avoid abuse of this construction, but
> it's still useful or necessary sometimes, as probably in your case, so
> you can silence it i think.
IMO, just receiving and passing *args, **kwargs "as is" is not magic,
as long as they are not used at all (no change, and no item access).
I use *args and **kwargs almost exclusively this way.
I see it as a way to redirect a function call, with no change to the arguments.
Do you think that the warning could be silenced in this case?
--
Amaury Forgeot d'Arc
More information about the Python-Projects
mailing list