Skip to content

Commit 6f7dd76

Browse files
authored
Run linters/formatters via pre-commit (#226)
1 parent 1f22e03 commit 6f7dd76

5 files changed

Lines changed: 39 additions & 13 deletions

File tree

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@ env:
88
FORCE_COLOR: 1
99

1010
jobs:
11-
black:
12-
name: Check formatting with black
11+
pre-commit:
12+
name: Check pre-commit hooks
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
1616
with:
1717
python-version: '3.13'
1818
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # 6.0.3
19-
- run: pip install -r requirements.txt
20-
- run: |
21-
black --version
22-
black --check .
19+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # 3.0.1
2320

2421
mypy:
2522
name: Check stub_uploader with mypy

.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# generated files -- trailing whitespace etc. doesn't matter too much for these
2+
exclude: (?x)^(data/.*)$
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
7+
hooks:
8+
- id: trailing-whitespace
9+
- id: end-of-file-fixer
10+
- id: check-yaml
11+
- id: check-merge-conflict
12+
- id: mixed-line-ending
13+
args: [--fix=lf]
14+
- id: check-case-conflict
15+
- repo: https://github.com/python-jsonschema/check-jsonschema
16+
rev: 12e63946db2c5cfcc9030fac21c3883ba88c6ed8 # frozen: 0.38.0
17+
hooks:
18+
- id: check-github-workflows
19+
- repo: https://github.com/psf/black-pre-commit-mirror
20+
rev: 4160603246a6b365d4a2af661c6d71b0a0f50478 # frozen: 26.5.1
21+
hooks:
22+
- id: black
23+
- repo: meta
24+
hooks:
25+
- id: check-hooks-apply
26+
27+
ci:
28+
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks"
29+
autofix_prs: true
30+
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
31+
autoupdate_schedule: quarterly
32+
submodules: false

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ The directory layout is self-explanatory:
1818
There are four GitHub actions in the repository. Here is a brief explanation
1919
of the role of each action.
2020

21-
### Check scripts (CI)
21+
### Check (CI)
2222

23-
[This CI action](https://github.com/typeshed-internal/stub_uploader/actions?query=workflow%3A%22Check+scripts%22)
24-
simply runs mypy and tests on each PR and push. You don't need to run it manually.
23+
[This CI action](https://github.com/typeshed-internal/stub_uploader/actions?query=workflow%3A%22Check%22)
24+
simply runs mypy, linters/formatters and tests on each PR and push. You don't need to run it manually.
2525

2626
### Test PyPI API token
2727

requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,3 @@ twine
1111
mypy
1212
pytest
1313
types-requests
14-
15-
# formatting
16-
black >= 26.5.1, < 27

tests/test_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def test_process_git_log() -> None:
349349
commit 337fd828e819988af2d3600283d8068bbbab7f50
350350
351351
Bump setuptools to 80.7.* (#14069)
352-
352+
353353
Body text #12345 python/typeshed#12345 https://example.com/#123
354354
355355
commit 58f581cea1a5040a733e6284adf81bf0793ac26a

0 commit comments

Comments
 (0)