Skip to content

Commit 2a174b2

Browse files
authored
CONTRIBUTING: introduce pre-commit (open-telemetry#2479)
1 parent 5116305 commit 2a174b2

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/psf/black-pre-commit-mirror
3+
rev: 24.3.0
4+
hooks:
5+
- id: black
6+
language_version: python3.11
7+
- repo: https://github.com/pycqa/isort
8+
rev: 5.12.0
9+
hooks:
10+
- id: isort
11+
- repo: https://github.com/pycqa/flake8
12+
rev: '6.1.0'
13+
hooks:
14+
- id: flake8

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ An easier way to do so is:
7070
1. Run `.tox/lint-some-package/bin/black .`
7171
2. Run `.tox/lint-some-package/bin/isort .`
7272

73+
Or you can call formatting and linting in one command by [pre-commit](https://pre-commit.com/):
74+
75+
```console
76+
$ pre-commit
77+
```
78+
79+
You can also configure it to run lint tools automatically before committing with:
80+
81+
```console
82+
$ pre-commit install
83+
7384
See
7485
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini)
7586
for more detail on available tox commands.

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ codespell==2.1.0
1717
requests==2.31.0
1818
ruamel.yaml==0.17.21
1919
flaky==3.7.0
20+
pre-commit==3.7.0; python_version >= '3.9'
21+
pre-commit==3.5.0; python_version < '3.9'

0 commit comments

Comments
 (0)