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

Lint unused imports in init modules #447

Closed
wants to merge 3 commits into from

Conversation

c24t
Copy link
Member

@c24t c24t commented Feb 25, 2020

@c24t c24t requested a review from a team February 25, 2020 23:28
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find, thanks for fixing this.

@c24t
Copy link
Member Author

c24t commented Feb 26, 2020

% pylint examples/http/__init__.py
************* Module http
examples/http/__init__.py:2:0: W0611: Unused namedtuple imported from collections (unused-import)

No idea why pylint is failing. The module is empty and nothing in the examples package imports collections. Changing the name from http makes pylint pass, so I'm guessing some namespace problem.

@Oberon00
Copy link
Member

@c24t Didn't you already work-around a very similar issue once?

@c24t
Copy link
Member Author

c24t commented Feb 28, 2020

@c24t Didn't you already work-around a very similar issue once?

IIRC something like this for requests. It looks like pylint find the built-in http module, lints it, and then reports that error as belonging to our http package/module... even when it's just an empty file.

% pylint examples/http/

************* Module http
examples/http/__init__.py:2:0: W0611: Unused namedtuple imported from collections (unused-import)

-----------------------------------
Your code has been rated at 9.83/10

Same error (but only one of two?) for built-in http:

% pylint $(python -c "import http; print(http.__file__)")
************* Module http
/root/.pyenv/versions/3.8.1/lib/python3.8/http/__init__.py:5:0: E0102: class already defined line 5 (function-redefined)
/root/.pyenv/versions/3.8.1/lib/python3.8/http/__init__.py:2:0: W0611: Unused namedtuple imported from collections (unused-import)

-----------------------------------
Your code has been rated at 9.12/10

Changing the name "fixes" the problem:

% mv examples/http/ examples/http_too/
% pylint examples/http_too/

------------------------------------
Your code has been rated at 10.00/10

@c24t
Copy link
Member Author

c24t commented Feb 28, 2020

FWIW changing pylint's confidence threshold fixes this too, but I'm not sure what other errors that might mask:

% pylint --confidence=INFERENCE_FAILURE examples/http/

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

@codeboten
Copy link
Contributor

This is currently not working with pylint so long as we have modules with conflicting names. Closing for now.

@codeboten codeboten closed this May 21, 2020
@c24t
Copy link
Member Author

c24t commented May 21, 2020

Fixing this would require extensive renaming or fixing pylint's name resolution problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants