Skip to content

Remove pylint process from github workflow #109

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

Merged

Conversation

hugodahl
Copy link
Contributor

@hugodahl hugodahl commented Feb 22, 2021

This pull-request addresses issue #104, by moving the pylint process from being part of the GitHub workflow (from .github/workflows/build.yml) to being part of the pre-commit workflow, so that it can be run on individual contributors' computers.

@tannewt tannewt requested a review from kattni February 23, 2021 00:50
@askpatrickw
Copy link
Contributor

Hey @hugodahl I think you're really close on this. Try the PR again, but remove all the commented out lines.

@kattni
Copy link
Contributor

kattni commented Feb 23, 2021

@hugodahl I only see the removal of Pylint from the build.yml file, and not the addition of it to the pre-commit. Please let me know if I'm missing something. I don't see anything in other PRs.

@hugodahl
Copy link
Contributor Author

This should be a draft pull request. At least that's what I'd clicked when I created it! Wouldn't be my first time clicking the wrong button... on any day!

@kattni
Copy link
Contributor

kattni commented Feb 23, 2021

No worries! I simply wanted to make sure I wasn't missing something. Thanks for putting it into draft status!

The installation of pylint within the workflow is still needed, since
the pre-commit execution of pylint is run through a shell call.
Since it isn't being run through the dedicated pre-commit hook, pre-commit
will not install pylint for us.
The pre-commit configuration file has had the calls to pylint for both
the library code (./adafruit_*.py) and example code (./examples/*.py)
added. The two calls are independant from one-another, and are named
respectively "pylint-library" and "pylint-examples".

The benefit of two separate calls is that they are easily
distinguishable from one another, their rules are applied specifically
to the correct patterns, and the comparison behaviour can be adjusted
independantly (compare all files together as a batch versus
individually).

Additionally, a shell call was the only way to work
around the pylint issue introduced in 2.7.0 which was causing duplicate
code errors to fail the validation, which should not be an issue for the
"examples/*.py" files, since each example should stand on its own.
@hugodahl hugodahl force-pushed the feature/Update-pre-commit-to-perform-pylint branch from 05c794d to 0581192 Compare February 24, 2021 02:39
@hugodahl
Copy link
Contributor Author

I've made the initial change to have the pylint calls be done in pre-commit. However, given that there's a little time this evening, I would like to try and make the library code execution use the pre-commit hook for pylint, rather than the shell execution. This would help keep things neater and more in line with how we would expect pylint to work, if not for the current 2.7.0 issue with the ./examples/*.py checks.

@hugodahl hugodahl marked this pull request as ready for review February 24, 2021 03:57
Copy link
Contributor

@askpatrickw askpatrickw left a comment

Choose a reason for hiding this comment

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

I tested this locally on my Mac and pushed the changes to my library and it ran successfully.
https://github.com/askpatrickw/CircuitPython_BloomSky/actions/runs/594815776

@kattni should review as well

Copy link
Contributor

@kattni kattni left a comment

Choose a reason for hiding this comment

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

This is amazing! I've tested it successfully. This is exactly what I needed.

I have one request below. Then we can get this merged and patched across the rest of the libraries!

Per discussion with @kattni in Discord (https://discord.com/channels/327254708534116352/327298996332658690/814157848400887809), the `bad-whitespace` check has been removed from pylint. To avoid future issues where it may be removed, we're pre-emptively removing it from our call.

The check which was performed by this rule is now handled in "black".
Copy link
Contributor

@kattni kattni left a comment

Choose a reason for hiding this comment

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

Thank you!!

@kattni kattni merged commit 1d56382 into adafruit:master Feb 24, 2021
@hugodahl hugodahl deleted the feature/Update-pre-commit-to-perform-pylint branch February 25, 2021 19:08
@jepler
Copy link
Contributor

jepler commented Mar 1, 2021

Did this work out? I've been researching pylint & pre-commit and found that the recommendation is to NOT actually use repo: https://github.com/pycqa/pylint in pre-commit -- see pre-commit/pre-commit-hooks#157 and https://pre-commit.com/#repository-local-hooks

I switched my own (non-circuitpython) project to a stanza like

-   repo: local
    hooks:
    -   id: pylint
        name: pylint
        entry: pylint
        language: python
        types: [python]
        additional_dependencies: [beautifulsoup4, requests, pylint]

otherwise I got import-error diagnostics from pylint.

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.

4 participants