Jean-Michel,

Thanks for the reply. We ended up using the pylint disable comment as well
for one or two unrelated cases. That's a cool feature.

Dan, Jürgen,

Thanks. I think I know what you mean. I consulted with the developers (I am
a QA person BTW) about the idea of wrapping the missing modules.
Unfortunately, they're not going to fix it. So I tried to write a custom
checker by extending the ImportsChecker and getting:

E               OptionConflictError: option --deprecated-modules:
conflicting option string(s): --deprecated-modules

This is the custom checker which I plug in the config file like so
'load-plugins=my_import_checker' :

import re

from logilab import astng
from pylint.checkers.imports import ImportsChecker

class MyImportChecker(ImportsChecker):

    def __init__(self, linter=None):
        self.msgs['R0402'] = ('Unable to import %r because this is not
Windows',
                              'Demote result to REFACTOR as this is a
WONTFIX')
        ImportsChecker.__init__(self, linter)

    def get_imported_module(self, modnode, importnode, modname):
        try:
            return importnode.do_import_module(modname)
        except astng.InferenceError, ex:
            if re.search('win32|pywin', modname) is not None:
                self.add_message("R0402", args=modname, node=importnode)
            else:
                self.add_message("F0401", args=modname, node=importnode)

def register(linter):
    """required method to auto register this checker """
    linter.register_checker(MyImportChecker(linter))

Does anyone know what is wrong? Thank you very much all.

-hans

2011/4/29 Jean-Michel Pichavant <[email protected]>

> Hans Sebastian wrote:
>
>> Hi,
>>
>> I need help or suggestions from you guys for a problem that I have with
>> pylint code E0401:
>>
>> F0401:  6: Unable to import 'win32api'
>> F0401:  6: Unable to import 'win32con'
>>
>> The software/package that I run pylint against supports multiple
>> platforms. One of them is Windows and for the windows build it's dependent
>> on python modules for windows extensions. The problem is when I run it on
>> non-windows, I get results such as above. Is there a way for me to run
>> pylint on non-windows machine and somehow ignore these modules? Are there
>> different ways that people have done? Thanks a lot for any reply.
>>
>> -hans
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Python-Projects mailing list
>> [email protected]
>> http://lists.logilab.org/mailman/listinfo/python-projects
>>
> import sys
>
> if sys.platform == 'win32':
>   # pylint: disable=E0401
>   import win32api
>
>
> This will locally disable the error.
>
> JM
>
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to