[code quality] new make target that combines style and quality targets (#7310)
* [code quality] merge style and quality targets Any reason why we don't run `flake8` in `make style`? I find myself needing to run `make style` and `make quality` all the time, but I need the latter just for the last 2 checks. Since we have no control over the source code why bother with separating checking and fixing - let's just have one target that fixes and then performs the remaining checks, as we know the first two have been done already. This PR suggests to merge the 2 targets into one efficient target. I will edit the docs if this change resonates with the team. * move checks into style, re-use target * better name * add fixup target * document new target
This commit is contained in:
@@ -170,13 +170,19 @@ Follow these steps to start contributing:
|
|||||||
$ make style
|
$ make style
|
||||||
```
|
```
|
||||||
|
|
||||||
`transformers` also uses `flake8` to check for coding mistakes. Quality
|
`transformers` also uses `flake8` and a few custom scripts to check for coding mistakes. Quality
|
||||||
control runs in CI, however you can also run the same checks with:
|
control runs in CI, however you can also run the same checks with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ make quality
|
$ make quality
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can do the automatic style corrections and code verifications that can't be automated in one go:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ make fixup
|
||||||
|
```
|
||||||
|
|
||||||
If you're modifying documents under `docs/source`, make sure to validate that
|
If you're modifying documents under `docs/source`, make sure to validate that
|
||||||
they can still be built. This check also runs in CI. To run a local check
|
they can still be built. This check also runs in CI. To run a local check
|
||||||
make sure you have installed the documentation builder requirements, by
|
make sure you have installed the documentation builder requirements, by
|
||||||
|
|||||||
15
Makefile
15
Makefile
@@ -1,20 +1,25 @@
|
|||||||
.PHONY: quality style test test-examples docs
|
.PHONY: quality_checks quality style fixup test test-examples docs
|
||||||
|
|
||||||
# Check that source code meets quality standards
|
# Check that source code meets quality standards
|
||||||
|
|
||||||
quality:
|
quality_checks:
|
||||||
black --check examples templates tests src utils
|
|
||||||
isort --check-only examples templates tests src utils
|
|
||||||
flake8 examples templates tests src utils
|
flake8 examples templates tests src utils
|
||||||
python utils/check_copies.py
|
python utils/check_copies.py
|
||||||
python utils/check_repo.py
|
python utils/check_repo.py
|
||||||
|
|
||||||
# Format source code automatically
|
quality:
|
||||||
|
black --check examples templates tests src utils
|
||||||
|
isort --check-only examples templates tests src utils
|
||||||
|
${MAKE} quality_checks
|
||||||
|
|
||||||
|
# Format source code automatically and check is there are any problems left that need manual fixing
|
||||||
|
|
||||||
style:
|
style:
|
||||||
black examples templates tests src utils
|
black examples templates tests src utils
|
||||||
isort examples templates tests src utils
|
isort examples templates tests src utils
|
||||||
|
|
||||||
|
fixup: style quality_checks
|
||||||
|
|
||||||
# Make marked copies of snippets of codes conform to the original
|
# Make marked copies of snippets of codes conform to the original
|
||||||
|
|
||||||
fix-copies:
|
fix-copies:
|
||||||
|
|||||||
Reference in New Issue
Block a user