Skip to content

Commit

Permalink
Merge pull request #10348 from mhilbrunner/pre-commit
Browse files Browse the repository at this point in the history
CI: Integrate pre-commit for style checks
  • Loading branch information
mhilbrunner authored Nov 30, 2024
2 parents 5dd44e6 + f9e72e2 commit 522bc83
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 54 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
# Install tools used by `_tools/format.sh`.
sudo apt-get -qq update
sudo apt-get -qq install dos2unix recode
sudo pip3 install -r requirements.txt
sudo pip3 install codespell
- name: Linter checks
run: |
bash _tools/format.sh
- name: Style checks via pre-commit
uses: pre-commit/[email protected]

codespell -D- -D _tools/codespell-dict.txt -I _tools/codespell-ignore.txt -x _tools/codespell-ignore-lines.txt -S tutorials/i18n/locales.rst {about,community,contributing,getting_started,tutorials}/{*.rst,**/*.rst,**/**/*.rst,**/**/**/*.rst}
- name: Install dependencies
run: sudo pip3 install -r requirements.txt

# Use dummy builder to improve performance as we don't need the generated HTML in this workflow.
- name: Sphinx build
Expand Down
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default_language_version:
python: python3

repos:
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
files: ^(about|community|contributing|getting_started|tutorials)/.*\.rst$
additional_dependencies: [tomli]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: fix-byte-order-marker
- id: mixed-line-ending
args: ['--fix=lf']
42 changes: 0 additions & 42 deletions _tools/format.sh

This file was deleted.

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tool.ruff]
line-length = 120

[tool.codespell]
dictionary = ["_tools/codespell-dict.txt", "-"]
ignore-words = "_tools/codespell-ignore.txt"
exclude-file = "_tools/codespell-ignore-lines.txt"
skip = "tutorials/i18n/locales.rst"

0 comments on commit 522bc83

Please sign in to comment.