-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Lint with pre-commit #7900
Conversation
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.
There was a problem hiding this 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. 👍
I think the github action won't run until merged to the master branch 🤔 |
Yes, that happens. Go for it. 👍 |
Question... when does the ".github/workflows/pre-commit.yml" workflow run? Can you link to an example? |
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 |
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.
Following my comment here and Django's own move to pre-commit.
runtests.py
code for running linting tools.runtests.py --fast
flag, since that would now just runpytest -q
, which can be done withruntests.py -q
instead.