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

[WIP] pylint and related cleanups #6002

Closed
wants to merge 15 commits into from

Conversation

pradyunsg
Copy link
Member

pylint is a pretty noisy and powerful linter, capable of detecting code smells and in general is more capable than flake8. One place where pylint's superior rule disabling capabilities 1 will be handy is the typing import ignores, where we won't have to annotate the every line.

It does however need some configuration before being usable. My current plan is to use pylint for a bit, get to know which linting rules are actually useful, have a discussion about them then finally adopt them for us.

As an example, this PR contains cleanups for 2 rules, I think would be reasonable to adopt. There's a couple of extra changes here as well but they're basically parts that pylint flagged and I saw a cleaner way to fix them. I suggest reviewing this PR commit by commit and looking at the entire function's body when reviewing the changes.

If @pypa/pip-committers are okay with adding pylint to our CI, let's do this. :)


TODO:

  • What are the good rules?
  • Figure out how to deal with existing code issues
    • Initial Plan: Fix them if trivial, otherwise # pylint: disable=....
  • Add to CI

@pradyunsg pradyunsg added skip news Does not need a NEWS file entry (eg: trivial changes) type: maintenance Related to Development and Maintenance Processes labels Nov 10, 2018
Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

I'm personally in favor 👍

Copy link
Member

@cjerdonek cjerdonek left a comment

Choose a reason for hiding this comment

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

Some quick comments. I'm not opposed to using a new linter.

src/pip/_internal/utils/filesystem.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/filesystem.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/filesystem.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/misc.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/misc.py Show resolved Hide resolved
@pradyunsg
Copy link
Member Author

Bwahahahaha. InstallRequirement bites here as well.

pylint crashes when run on req_install.py: pylint-dev/pylint#2591 (comment). After spending a more-than-justified amount of time digging through pylint's and astroid's code (in vain), I found a wonderful workaround, on pylint's issue tracker, for hitting the recursion limit:

--init-hook="import sys; sys.setrecursionlimit(10000)"

:')


In other news, over the next 2 weeks, I have my semester-end exams. Hopefully for my academics, I'll be spotted rarely during that time. I might start working on #5051 in the mean time. :)

@pradyunsg
Copy link
Member Author

pradyunsg commented Nov 15, 2018

I've added 4 new commits (no new rules yet) and rebased to include current master and PEP 517 changes. ✨

@pradyunsg pradyunsg force-pushed the linter-guided-cleanups branch from 7267e92 to a6351b9 Compare November 15, 2018 20:02
@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Dec 6, 2018
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Dec 7, 2018
@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Dec 16, 2018
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Dec 21, 2018
@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Feb 8, 2019
@pradyunsg
Copy link
Member Author

Me wants to do this. Will do it, eventually. Closing due to lack of time.

@pradyunsg pradyunsg closed this May 23, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 22, 2019
@pradyunsg pradyunsg deleted the linter-guided-cleanups branch September 30, 2019 10:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation needs rebase or merge PR has conflicts with current master skip news Does not need a NEWS file entry (eg: trivial changes) type: maintenance Related to Development and Maintenance Processes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants