On Thu, Apr 28, 2011 at 1:05 PM, Hans Sebastian <[email protected]> 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.
I've been doing the following.
If I start out with:
File A:
try:
import pyx_thing as py_thing
except ImportError:
import py_thing
py_thing.start()
...then this fails in pylint on Python interpreters that don't have the
Cython (pyx) module I need, even though it runs fine.
So I change it to:
File A:
import pyx_wrapper as py_thing
py_thing.start()
File pyx_wrapper.py:
try:
from pyx_thing import *
except ImportError:
from py_thing import *
...and then I pass File A to pylint, but not pyx_wrapper. The intent, of
course, is to keep pyx_wrapper (or in your case, win32_wrapper or something)
as minimal as possible, so that all it has is things that are legitimate to
my relevant python interpreters, but also things that annoy pylint.
I like to use one such wrapper for each module that needs to be hidden from
pylint - to avoid namespace collisions.
--
Dan Stromberg
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects