Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lint with pre-commit #7900

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
merged 5 commits into from
Apr 5, 2021
Merged

Lint with pre-commit #7900

merged 5 commits into from
Apr 5, 2021

Conversation

adamchainz
Copy link
Contributor

Following my comment here and Django's own move to pre-commit.

  • Add pre-commit config file to run flake8 and isort.
  • Add extra "common sense" hooks.
  • Run pre-commit on GitHub actions using the official action. This is a good way to get up-and-running but it would be better if we activated pre-commit.ci, which is faster and will auto-update the hooks for us going forwards.
  • Remove runtests.py code for running linting tools.
  • Remove runtests.py --fast flag, since that would now just run pytest -q, which can be done with runtests.py -q instead.
  • Remove tox configuration and requirements files for linting.
  • Update the contributing guide to mention setting up pre-commit.

Following [my comment here](encode#7589 (comment)) and [Django's own move to pre-commit](https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#pre-commit-checks).

* Add pre-commit config file to run flake8 and isort.
* Add extra "common sense" hooks.
* Run pre-commit on GitHub actions using the [official action](https://github.com/pre-commit/action/). This is a good way to get up-and-running but it would be better if we activated [pre-commit.ci](https://pre-commit.ci/), which is faster and will auto-update the hooks for us going forwards.
* Remove `runtests.py` code for running linting tools.
* Remove `runtests.py --fast` flag, since that would now just run `pytest -q`, which can be done with `runtests.py -q` instead.
* Remove tox configuration and requirements files for linting.
* Update the contributing guide to mention setting up pre-commit.
@adamchainz adamchainz requested a review from carltongibson April 5, 2021 09:49
Copy link
Collaborator

@carltongibson carltongibson 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 happy for us to add this. Saves a few cycles generally I think. 👍

@adamchainz
Copy link
Contributor Author

I think the github action won't run until merged to the master branch 🤔

@carltongibson
Copy link
Collaborator

I think the github action won't run until merged to the master branch 🤔

Yes, that happens. Go for it. 👍

@adamchainz adamchainz merged commit aa12a5f into encode:master Apr 5, 2021
@adamchainz adamchainz deleted the pre-commit branch April 5, 2021 11:08
@tomchristie
Copy link
Member

Question... when does the ".github/workflows/pre-commit.yml" workflow run? Can you link to an example?

@adamchainz
Copy link
Contributor Author

It runs the hooks on all files on every CI run from now on, completing in ~20 seconds: https://github.com/encode/django-rest-framework/actions/workflows/pre-commit.yml

It's based on the action's docs: https://github.com/pre-commit/action

sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
Following [my comment here](encode#7589 (comment)) and [Django's own move to pre-commit](https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#pre-commit-checks).

* Add pre-commit config file to run flake8 and isort.
* Add extra "common sense" hooks.
* Run pre-commit on GitHub actions using the [official action](https://github.com/pre-commit/action/). This is a good way to get up-and-running but it would be better if we activated [pre-commit.ci](https://pre-commit.ci/), which is faster and will auto-update the hooks for us going forwards.
* Remove `runtests.py` code for running linting tools.
* Remove `runtests.py --fast` flag, since that would now just run `pytest -q`, which can be done with `runtests.py -q` instead.
* Remove tox configuration and requirements files for linting.
* Update the contributing guide to mention setting up pre-commit.
@adamchainz adamchainz mentioned this pull request Dec 8, 2022
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