[Python-projects] Supress checknig of imported module?

Duncan Gibson duncan.gibson at xs4all.nl
Thu Nov 20 16:28:24 CET 2008


> I don't want to globally supress E1101 and I dont want to supress
> the error on ever line where I use omniDerivedThing. Is there a way
> to tell pylint to ignore a particular imported module? I looked at
> the --ignore= command line option but that didn't seem to work - I
> assume that just prevents pylinting that file, rather than things>
> that are using that file.
>
> Any help gratefully received!

I had a similar problem with an EnumerationType abstract base class
written or adapted by a colleague, where each subclass was defined:

class MyEnum(EnumerationType):
    pass
MyEnum.initialize('YES', 'NO', 'MAYBE')

and subsequent code could use MyEnum.YES, MyEnum.NO and MyEnum.MAYBE
These trigger a __hasattr__() call which returns the integer value.

Of course pylint gave E1101 warnings about the usage, until I got
fed up and changed the class declaration to include class variables
with the same names but which would then be masked by the machinery
set up by initialize():

class MyEnum(EnumerationType):
    pass
    YES = None
    NO = None
    MAYBE = None

Is there some way that you could introduce a dummy omniDerivedThing
class, with initialisation of anEnumConstant for use with pylint?

Of course this also raises the question whether it is possible to
code something like the following:

if pylint:
    create/import dummy code
else:
    create/import real code

Cheers
Duncan




More information about the Python-Projects mailing list