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

False Positive: 'Attempted relative import beyond top-level package' #3629

Closed
cm107 opened this issue May 16, 2020 · 3 comments
Closed

False Positive: 'Attempted relative import beyond top-level package' #3629

cm107 opened this issue May 16, 2020 · 3 comments
Labels
Bug 🪲 Duplicate 🐫 Duplicate of an already existing issue Regression

Comments

@cm107
Copy link

cm107 commented May 16, 2020

Steps to reproduce

  1. Install the latest version of pylint (2.5.2)
pip install pylint==2.5.2
  1. Create a simple package folder with a pair of scripts that use a relative import.
mkdir pkg_folder
cd pkg_folder
touch __init__.py
code test0.py test1.py

test0.py

class Test0:
    def __init__(self):
        pass

test1.py

from .test0 import Test0

class Test1:
    def __init__(self):
        super().__init__()
        pass

Notice that pylint is giving you an 'Attempted relative import beyond top-level package' error.
image
3. Verify that you are not going crazy: Install an older version of pylint that should work correctly.

pip install pylint==2.4.4

image

The error went away.
In other words, there's something wrong with version 2.5.2.

Current behavior

pylint is gives an 'Attempted relative import beyond top-level package' error when it is not warranted. This is a false positive.

Expected behavior

This error should not be shown.

pylint --version output

pylint 2.5.2
astroid 2.4.1
Python 3.7.3 (default, Jul 10 2019, 16:01:05)
[GCC 7.4.0]

@cm107 cm107 changed the title pip False Positive: 'Attempted relative import beyond top-level package' May 16, 2020
@Pierre-Sassoulas
Copy link
Member

Hello, thank you for reporting this problem. When you report a bug please do not use screenshot as it's not searchable (not readable by screen readers and impossible to find with a web search), instead copy paste the text output :)
There is less chance that we'll have to handle duplicate issues that way.

@jnsnow
Copy link
Contributor

jnsnow commented Jul 3, 2020

Is this a duplicate of #3624 ?

@Pierre-Sassoulas
Copy link
Member

Is does look like a duplicate, thank you @jnsnow

@Pierre-Sassoulas Pierre-Sassoulas added the Duplicate 🐫 Duplicate of an already existing issue label Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Duplicate 🐫 Duplicate of an already existing issue Regression
Projects
None yet
Development

No branches or pull requests

3 participants