سؤال

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top