Skip to content

Commit

Permalink
Run lint with pre-commit (#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin authored Aug 22, 2022
1 parent e093296 commit d5d79ae
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.8.0
hooks:
- id: isort

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"-rn",
"-j0",
"--rcfile=.pylintrc",
]
exclude: ^(docs/|changelog.py)
require_serial: true
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,10 @@ tox-env-clean:
rm -rf .tox

lint: check-venv
@. $(VENV_ACTIVATE_FILE); find esrally benchmarks scripts tests it -name "*.py" -exec pylint -j0 -rn --rcfile=$(CURDIR)/.pylintrc \{\} +
@. $(VENV_ACTIVATE_FILE); black --check --diff .
@. $(VENV_ACTIVATE_FILE); isort --check --diff .
@. $(VENV_ACTIVATE_FILE); pre-commit run --all-files

format: check-venv
@. $(VENV_ACTIVATE_FILE); black .
@. $(VENV_ACTIVATE_FILE); isort .
# pre-commit run also formats files, but let's keep `make format` for convenience
format: lint

docs: check-venv
@. $(VENV_ACTIVATE_FILE); cd docs && $(MAKE) html
Expand Down
2 changes: 2 additions & 0 deletions docs/developing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Rally uses automatic code formatters. They're enforced by ``make lint`` and you

However, consider using editor integrations to do it automatically: you'll need to configure `black <https://black.readthedocs.io/en/stable/integrations/editors.html>`_ and `isort <https://github.com/PyCQA/isort/wiki/isort-Plugins>`_.

Also consider running `pre-commit install` to run lint as part of your git commits.

Automatic Updates
~~~~~~~~~~~~~~~~~

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ develop = [
"twine==1.15.0",
"wheel==0.37.1",
"github3.py==1.3.0",
"pre-commit==2.20.0",
"pylint==2.6.0",
"black==22.3.0",
"isort==5.8.0",
"trustme==0.9.0",
"pytest-httpserver==1.0.4",
]
Expand Down

0 comments on commit d5d79ae

Please sign in to comment.