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

relative-beyond-top-level false positives with PEP 420 namespace #2967

Closed
abadger opened this issue Jun 18, 2019 · 2 comments · Fixed by #5059
Closed

relative-beyond-top-level false positives with PEP 420 namespace #2967

abadger opened this issue Jun 18, 2019 · 2 comments · Fixed by #5059
Labels
Bug 🪲 Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors High priority Issue with more than 10 reactions Import system
Milestone

Comments

@abadger
Copy link

abadger commented Jun 18, 2019

Steps to reproduce

hello-1.0.tar.gz

  1. wget https://github.com/PyCQA/pylint/files/3302704/hello-1.0.tar.gz
  2. tar -xzvf hello-1.0.tar.gz
  3. cd hello-1.0/
  4. pylint --reports n -d all -e relative-beyond-top-level hello/top.py
  5. The same error occurs with
    • pylint --reports n -d all -e relative-beyond-top-level hello/level2/plugin1.py
    • pylint --reports n -d all -e relative-beyond-top-level hello
  6. The error does not occur when using module notation:
    • pylint --reports n -d all -e relative-beyond-top-level hello.top
    • pylint --reports n -d all -e relative-beyond-top-level hello.level2.plugin1
    • However, I couldn't find a way to get pylint to treat pylint hello as specifying a module or package rather than a directory so there's no way to workaround that usage.

Current behavior

[pts/4@peru ~/tmp/hello-1.0]$ pylint --reports n -d all -e relative-beyond-top-level hello                (10:29:39)
************* Module top
hello/top.py:1:0: E0402: Attempted relative import beyond top-level package (relative-beyond-top-level)
************* Module level2.plugin1
hello/level2/plugin1.py:1:0: E0402: Attempted relative import beyond top-level package (relative-beyond-top-level)

--------------------------------------------------------------------
Your code has been rated at -2.50/10 (previous run: -2.50/10, +0.00)

Expected behavior

The same output as is currently reported by: pylint --reports n -d all -e relative-beyond-top-level hello.top

```
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
```

I'd like this to work with both pylint $TOPLEVEL and pylint $PATH_TO_MODULE_FILE. TOPLEVEL is what I use for my manual pylint runs. PATH_TO_MODULE_FILE is being used by ALE and likely other checkers integrated into IDEs and text editors.

(Bug I opened against ALE to try to find a workaround for this: dense-analysis/ale#2597 )

pylint --version output

pylint 2.3.1
astroid 2.2.5
Python 3.7.3 (default, May 11 2019, 00:45:16) 
[GCC 8.3.1 20190223 (Red Hat 8.3.1-2)]
@alexchandel
Copy link

Are there any workaround for this, when invoked from an IDE? Any command-line arguments or .pylintrc hacks?

@feluxe
Copy link

feluxe commented Nov 4, 2020

@alexchandel It can be diabled with --disable=E0402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors High priority Issue with more than 10 reactions Import system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants