Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError when using PEP 420 namespaces #1667

Closed
zacchiro opened this issue Sep 20, 2017 · 6 comments · Fixed by #7113
Closed

ImportError when using PEP 420 namespaces #1667

zacchiro opened this issue Sep 20, 2017 · 6 comments · Fixed by #7113
Assignees
Milestone

Comments

@zacchiro
Copy link

Steps to reproduce

  1. git clone http://forge.softwareheritage.org/source/swh-core.git
  2. export PYTHONPATH=$(pwd)/swh-core
  3. pylint3 swh.core

Current behavior

ImportError: Unable to find module for /tmp/swh-core/swh/core/api.py in /tmp,

(or equivalent)

Expected behavior

Should be able to walk the module and pylint it.
Note that both "import swh.core" and manually pylinting the specific module that pylint claims is not loadable (pylint3 swh.core.api) work just fine.

I've given more details about this issue on the code-quality at https://mail.python.org/pipermail/code-quality/2017-September/000937.html (no answer yet at the time of filing this).

I've seen there are a number of PEP 420 related issues, but as far as I can tell they are either supposed to be already fixed in the version of pylint I'm using, or the fail in different ways (e.g., with a proper "cannot load module" message instead of a runaway ImportError exception like in my case).

pylint --version output

pylint3 1.7.2,
astroid 1.5.3
Python 3.5.4 (default, Aug 12 2017, 14:08:14)
[GCC 7.1.0]

@PCManticore
Copy link
Contributor

Thanks for the report! We do have a couple of issues related to PEP 420, I'll have to take a look to see exactly why this is not working as intended. As you mentioned, linting with pylint swh/core works fine, but it should work with dot syntax as well.

@PCManticore PCManticore self-assigned this Sep 21, 2017
@PCManticore PCManticore added this to the 1.8.0 milestone Sep 21, 2017
@PCManticore
Copy link
Contributor

In the meantime, I'm going to assign this for the next release so we could fix all these PEP 420 problems before releasing 1.8.

@PCManticore PCManticore modified the milestones: 1.8.0, 2.0 Dec 12, 2017
@brycepg brycepg self-assigned this Mar 21, 2018
@PCManticore PCManticore modified the milestones: 2.0, 2.1 Apr 25, 2018
@brycepg brycepg assigned PCManticore and unassigned brycepg and PCManticore Jul 24, 2018
@PCManticore PCManticore added this to the Next bug fix release milestone Aug 1, 2018
@PCManticore PCManticore modified the milestones: Next bug fix release, Next minor release Aug 22, 2018
@PCManticore PCManticore removed this from the Next minor release milestone Sep 23, 2018
@arcivanov
Copy link

I'm surprised this hasn't been fixed yet. Pylint simply does not work with implicit namespaces at all. Case in point: pybuilder/pybuilder#818 (comment)

@Pierre-Sassoulas Pierre-Sassoulas changed the title pylint3 ImportError when using PEP 420 namespaces ImportError when using PEP 420 namespaces Oct 11, 2021
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 12, 2021
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 13, 2021
arcivanov added a commit to pybuilder/pybuilder that referenced this issue Oct 13, 2021
@DanielNoord
Copy link
Collaborator

I have tried to reproduce this on main but was able to lint the package. Are we sure this is still not fixed?

There are many issues with namespace packages but I wonder if this one has been fixed already.

@Pierre-Sassoulas
Copy link
Member

I created a label for namespace-package so we can track and close them. There's probably a lot of near-duplicates.

@jacobtylerwalls
Copy link
Member

Fixed in pylint-dev/astroid#1576 -- I'll try to get to a regression test tomorrow.

@jacobtylerwalls jacobtylerwalls added this to the 2.15.0 milestone Jul 2, 2022
@jacobtylerwalls jacobtylerwalls added the Astroid Related to astroid label Jul 2, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the Needs PR This issue is accepted, sufficiently specified and now needs an implementation label Jul 2, 2022
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Jul 2, 2022
@jacobtylerwalls jacobtylerwalls removed the Needs PR This issue is accepted, sufficiently specified and now needs an implementation label Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants