开发者

pylint import and dynamic path modification

My projects are generally structured like this:

projectname/
    __init__.py
    python/
        mymodule.py
    other_stuff/
    more_stuff/

where __init__.py contains the following code

import os
mypath = os.path.dirname(os.path.realpath(os.path.abspath(__file__)))
__path__ = [mypath, mypath+"/python"]

This "skips" the python directory when importing to allow python code in the form from projectname import mymodule rather than from projectname.python import mymodule.

This appears to break pylint however, being unable to import any modules in the project despite $PYTHONPATH being set correctly. Creating a softlink projectname -&开发者_如何学Gogt; python in the projectname fixes things but isn't a suitable solution.

Any suggestions on how to fix this without altering the directory structure?


I think you're kind of stuck. Pylint doesn't process your __init__.py file so unless you can find another way of getting that information into pylint, I don't think it's going to work. Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜