-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Regression: explicit relative imports in modules with __init__.py trigger E0402 relative-beyond-top-level #3624
Comments
This is to work around a bug introduced in pylint 2.5.1 pylint-dev/pylint#3624
@PCManticore I have one more facet of this to report that differs slightly from my above report. It might be the same as in #3651 ? The structure I am prototyping for QEMU upstream is now:
i.e. qemu is a PEP420 namespace, core is the package.
from .accel import kvm_available, list_accel, tcg_available
from .machine import QEMUMachine
from .qmp import QEMUMonitorProtocol
from .qtest import QEMUQtestMachine, QEMUQtestProtocol Starting from the containing directory, i.e.
2.4.4: OK 2.5.0:
2.5.1, 2.5.2, 2.5.3, 2.6.0: (Tested on 3.6. 2.6.0 was tested in 3.6, 3.7, and 3.8)
|
Pylint 2.5.x - 2.7.x have regressions that make import checking inconsistent, see: pylint-dev/pylint#3609 pylint-dev/pylint#3624 pylint-dev/pylint#3651 Pinning to 2.4.4 is worse, because it mandates versions of shared dependencies that are too old for features we want in isort and mypy. Oh well. Signed-off-by: John Snow <[email protected]> Reviewed-by: Cleber Rosa <[email protected]> Message-id: [email protected] Signed-off-by: John Snow <[email protected]>
Pylint 2.5.x - 2.7.x have regressions that make import checking inconsistent, see: pylint-dev/pylint#3609 pylint-dev/pylint#3624 pylint-dev/pylint#3651 Pinning to 2.4.4 is worse, because it mandates versions of shared dependencies that are too old for features we want in isort and mypy. Oh well. Signed-off-by: John Snow <[email protected]> Reviewed-by: Cleber Rosa <[email protected]> Message-id: [email protected] Signed-off-by: John Snow <[email protected]>
I've attempted to reproduce this issue and can confirm that with pylint 2.15.4 the |
Issue #3528 and associated PR #3569 appear to have caused a regression in how modules with
__init__.py
are perceived.If I install a dev copy of 4756b3c (origin/master as of writing) and revert this change, the explicit relative import works again.
Steps to reproduce
layout:
qtest.py has an import statement like this:
If CWD is
qemu/lib
and I execute:> pylint qtest.py
2.4.4:
2.5.0:
but 2.5.1:
Current behavior
Relative imports trigger
relative-beyond-top-level
messages.Expected behavior
As the relative imports function correctly during runtime, pylint should not produce an Error.
pylint --version output
Current setup:
More info:
From what I can tell, it seems as if the fact that I have an
__init__.py
is getting ignored (?), and my file is being processed as if it wasn't in a package. I seem to recall that what 'self.name' resolved to insiderelative_to_absolute_name
was surprisingly different, but naturally I didn't write it down...The text was updated successfully, but these errors were encountered: