diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..cbdffe129b2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.3.0 + hooks: + - id: black + language_version: python3.11 + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + - repo: https://github.com/pycqa/flake8 + rev: '6.1.0' + hooks: + - id: flake8 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 485cb6a0fcc..752eddb49f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,6 +61,18 @@ An easier way to do so is: 1. Run `.tox/lint/bin/black .` 2. Run `.tox/lint/bin/isort .` +Or you can call formatting and linting in one command by [pre-commit](https://pre-commit.com/): + +```console +$ pre-commit +``` + +You can also configure it to run lint tools automatically before committing with: + +```console +$ pre-commit install +``` + We try to keep the amount of _public symbols_ in our code minimal. A public symbol is any Python identifier that does not start with an underscore. Every public symbol is something that has to be kept in order to maintain backwards compatibility, so we try to have as few as possible. diff --git a/dev-requirements.txt b/dev-requirements.txt index 90385cc6fab..6a76060f325 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -19,3 +19,4 @@ asgiref==3.7.2 psutil==5.9.6 GitPython==3.1.41 flaky==3.7.0 +pre-commit==3.7.0