[Python-projects] Metaclass method should have "mcs" as first argument?

Sylvain Thénault sylvain.thenault at logilab.fr
Fri Jul 13 10:39:03 CEST 2007


On Tuesday 03 July à 19:20, Adrien Di Mascio wrote:
> Hi,
> 
> [Maarten ter Huurne]
> > 
> > When running PyLint on a metaclass I wrote, I get the following warning:
> > 
> > C0203:123:_SomeMeta.__iter__: Metaclass method should have "mcs" as first
> > argument
> > 
> > I wonder what the rationale behind this naming convention is. The first
> > argument to a normal metaclass method is the class it operates on.
> > Therefore, I had named the first argument "cls", just like the first
> > argument of classmethods on ordinary classes. Naming it "mcs" would lead me
> > to think that the metaclass itself is passed as the first argument, but
> > that is not the case.
> 
> I agree with you and I think it's a bug. 'mcs' is the argument name we
> generally use as the first __new__() parameter. IMHO, the check only
> makes sense in this particular case.

http://www.logilab.org/bug/eid/4014 

-- 
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