CONTRIBUTING: introduce pre-commit (#2479)

This commit is contained in:
Riccardo Magliocchetti
2024-05-02 19:11:02 +02:00
committed by GitHub
parent 5116305f77
commit 2a174b2543
3 changed files with 27 additions and 0 deletions

14
.pre-commit-config.yaml Normal file
View File

@ -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

View File

@ -70,6 +70,17 @@ An easier way to do so is:
1. Run `.tox/lint-some-package/bin/black .`
2. Run `.tox/lint-some-package/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
See
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini)
for more detail on available tox commands.

View File

@ -17,3 +17,5 @@ codespell==2.1.0
requests==2.31.0
ruamel.yaml==0.17.21
flaky==3.7.0
pre-commit==3.7.0; python_version >= '3.9'
pre-commit==3.5.0; python_version < '3.9'