Skip to content

Commit fbdc363

Browse files
authored
feat(dev): add pre-commit hooks for pyright, ruff and mypy (pythonarcade#2158)
1 parent 13c37e4 commit fbdc363

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
default_language_version:
2+
python: python3.9
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.5.0
7+
hooks:
8+
- id: check-yaml
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.5.0
13+
hooks:
14+
# Run the linter.
15+
- id: ruff
16+
args: [ --fix ]
17+
# Run the formatter.
18+
- id: ruff-format
19+
- repo: https://github.com/pre-commit/mirrors-mypy
20+
rev: 'v1.10.1'
21+
hooks:
22+
- id: mypy
23+
args: [ arcade, --explicit-package-bases ]
24+
- repo: https://github.com/RobertCraigie/pyright-python
25+
rev: v1.1.369
26+
hooks:
27+
- id: pyright

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ the formatting is correct.
9595
python make.py format
9696
```
9797

98+
### Use pre-commit hooks to automatically run formatting
99+
100+
You can use `pre-commit <https://pre-commit.com/>`_ to automatically run lint, formatting and type checks against
101+
your changes before you commit them.
102+
To install pre-commit, run the following command:
103+
104+
.. code-block:: shell
105+
106+
pip install pre-commit
107+
# or on Mac
108+
brew install pre-commit
109+
110+
Then, run the following command to install the pre-commit hooks:
111+
112+
.. code-block:: shell
113+
114+
pre-commit install
115+
98116
## Testing
99117

100118
You should test your changes locally before submitting a pull request

0 commit comments

Comments
 (0)