Search code examples
pythonimportpylint

Pylint doesn't handle imports when several projects have same base module name


We've got a series of code projects in different parts of our source tree that all have a base package company_name, and some of them import functionality from eachother. This works just fine when running the code, setuptools and declare_namespace handle peicing together the modules. However, pylint doesn't seem to be feeling the mojo, so a large number of files have large high-prio errors Unable to import X from company_name. PYTHONPATH doesn't help, maybe some magic in pylints --init-hook=? Any hints and ideas super welcome!


Solution

  • I have similar problem with import directory-based settings from many projects at once.

    My dirty solution is to make symlinks, each with different name (eg. projectA/settings -> projA_settings, projectB/settings -> projB_settings) and then use that import:

    import projA_settings
    

    or

    import projB_settings