[Python-projects] Mixin class give rise to false positive W0233

Sylvain Thénault sylvain.thenault at logilab.fr
Thu Nov 23 13:43:54 CET 2006


On Thursday 23 November à 11:48, Barry Scott wrote:
> All my class that derive from classes whose names end in Mixin get a W0233
> and mention of the infamous Yes object. Is this because classes that end 
> in mixin
> are not expected to have a __init__ at all? Or is it a bug?

I don't know exactly but I suspect something is going wrong with your
code or with our python path. Here is a (stripped) test I have done 
with the patch I sent you applied :

syt at corvus:test$ cat input/func_w0233.py
# pylint: disable-msg=R0903,W0212,W0403,W0406
"""test for call to __init__ from a non ancestor class
"""
class AAAA:

    def __init__(self):
        print 'init', self
        BBBBMixin.__init__(self)

class BBBBMixin:

    def __init__(self):
        print 'init', self

import nonexistant
import func_w0233
class CCC(BBBBMixin, func_w0233.AAAA, func_w0233.BBBB,
nonexistant.AClass):
    """mix different things, some inferable some not"""
    def __init__(self):
        BBBBMixin.__init__(self)
        func_w0233.AAAA.__init__(self)
        func_w0233.BBBB.__init__(self)
        nonexistant.AClass.__init__(self)
syt at corvus:test$ pylint -rn -iy --disable-msg=I0011 input/func_w0233.py
No config file found, using default configuration
************* Module input.func_w0233
W0233: 12:AAAA.__init__: __init__ method from a non direct base class 'BBBBMixin' is called

So it seems to deal correctly either with class ending by Mixin and with
uninferable classes.

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