Skip to content

Commit 510e25a

Browse files
authored
Maintenance rework (#35)
Major change to the pre-commit fixes & checks to align with the current state of https://learn.scientific-python.org/development/guides/style/ The main thing: Switching to ruff, motivated by problems updating the pre-commit tools (black made changes that flake8 then complained about). Using ruff replaces using black and flake8 directly. It has a long list of rules that can be configured. A lot of style changes were made automatically, and I've temporarily(?) disabled rules that caused a problem needing manual changes. Some minor fixes to CI, including switching from the deprecated pre-commit action to the pre-commit.ci application
1 parent c941eac commit 510e25a

33 files changed

+337
-277
lines changed

.flake8

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,18 @@ on:
44
workflow_dispatch:
55
pull_request:
66
branches: [ main, staging ]
7+
schedule:
8+
# Weekly on Sunday
9+
- cron: "0 1 * * 0"
710

811
jobs:
9-
pre-commit:
10-
name: Format
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v1
14-
- uses: actions/setup-python@v2
15-
- uses: pre-commit/[email protected]
16-
with:
17-
extra_args: --hook-stage manual --all-files
18-
1912
checks:
2013
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
2114
runs-on: ${{ matrix.runs-on }}
2215
strategy:
2316
fail-fast: false
2417
matrix:
25-
python-version: ["3.9", "3.10"]
18+
python-version: ["3.9", "3.10", "3.11"]
2619
runs-on: [ubuntu-latest, macos-latest, windows-latest]
2720

2821
# include:
@@ -36,9 +29,9 @@ jobs:
3629
run: brew reinstall gfortran
3730
shell: bash
3831

39-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v4
4033

41-
- uses: actions/setup-python@v2
34+
- uses: actions/setup-python@v5
4235
with:
4336
python-version: ${{ matrix.python-version }}
4437

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,8 @@ cython_debug/
141141
src/*/_version.py
142142

143143
# VSCode
144-
.vscode/*
144+
.vscode
145+
146+
# Other dev tool junk
147+
.ruff_cache
148+
node_modules

.pre-commit-config.yaml

Lines changed: 77 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,91 @@
11
exclude: ^(.*/data/.*)
22

33
repos:
4-
- repo: https://github.com/psf/black
5-
rev: 23.1.0
6-
hooks:
7-
- id: black-jupyter
4+
# Strip outputs from notebooks
5+
- repo: https://github.com/kynan/nbstripout
6+
rev: "0.7.1"
7+
hooks:
8+
- id: nbstripout
9+
args:
10+
["--extra-keys", "metadata.kernelspec metadata.language_info.version"]
811

9-
- repo: https://github.com/kynan/nbstripout
10-
rev: "0.6.1"
11-
hooks:
12-
- id: nbstripout
13-
args: ["--extra-keys", "metadata.kernelspec metadata.language_info.version"]
12+
# The rest of the checks are from:
13+
# https://github.com/scientific-python/cookie/blob/main/%7B%7Bcookiecutter.project_name%7D%7D/.pre-commit-config.yaml
1414

15-
- repo: https://github.com/pre-commit/pre-commit-hooks
16-
rev: v4.4.0
17-
hooks:
18-
- id: check-added-large-files
19-
- id: check-case-conflict
20-
- id: check-merge-conflict
21-
- id: check-symlinks
22-
- id: check-yaml
23-
- id: debug-statements
24-
- id: end-of-file-fixer
25-
- id: mixed-line-ending
26-
- id: requirements-txt-fixer
27-
- id: trailing-whitespace
15+
- repo: https://github.com/pre-commit/pre-commit-hooks
16+
rev: "v4.5.0"
17+
hooks:
18+
- id: check-added-large-files
19+
- id: check-case-conflict
20+
- id: check-merge-conflict
21+
- id: check-symlinks
22+
- id: check-yaml
23+
- id: debug-statements
24+
- id: end-of-file-fixer
25+
- id: mixed-line-ending
26+
- id: name-tests-test
27+
args: ["--pytest-test-first"]
28+
- id: requirements-txt-fixer
29+
- id: trailing-whitespace
2830

29-
- repo: https://github.com/pre-commit/pygrep-hooks
30-
rev: v1.10.0
31-
hooks:
32-
- id: python-check-blanket-noqa
33-
# - id: python-check-blanket-type-ignore
34-
- id: python-no-eval
35-
- id: python-use-type-annotations
36-
- id: rst-backticks
37-
- id: rst-directive-colons
38-
- id: rst-inline-touching-normal
31+
- repo: https://github.com/pre-commit/pygrep-hooks
32+
rev: "v1.10.0"
33+
hooks:
34+
- id: rst-backticks
35+
- id: rst-directive-colons
36+
- id: rst-inline-touching-normal
3937

40-
- repo: https://github.com/PyCQA/isort
41-
rev: 5.12.0
42-
hooks:
43-
- id: isort
44-
# args: ["-a", "from __future__ import annotations"] # Python 3.7+
38+
# - repo: https://github.com/pre-commit/mirrors-prettier
39+
# rev: "v4.0.0-alpha.8"
40+
# hooks:
41+
# - id: prettier
42+
# types_or: [yaml, markdown, html, css, scss, javascript, json]
43+
# args: [--prose-wrap=always]
4544

46-
- repo: https://github.com/asottile/pyupgrade
47-
rev: v3.3.1
48-
hooks:
49-
- id: pyupgrade
50-
args: ["--py37-plus"]
45+
- repo: https://github.com/astral-sh/ruff-pre-commit
46+
rev: "v0.2.1"
47+
hooks:
48+
- id: ruff
49+
args: ["--fix", "--show-fixes"]
50+
- id: ruff-format
5151

52-
# - repo: https://github.com/hadialqattan/pycln
53-
# rev: v1.1.0
54-
# hooks:
55-
# - id: pycln
56-
# args: [--config=pyproject.toml]
52+
# TODO: Enable type checking
53+
# - repo: https://github.com/pre-commit/mirrors-mypy
54+
# rev: "v1.8.0"
55+
# hooks:
56+
# - id: mypy
57+
# files: src|tests
58+
# args: []
59+
# additional_dependencies:
60+
# - pytest
5761

58-
- repo: https://github.com/asottile/yesqa
59-
rev: v1.4.0
60-
hooks:
61-
- id: yesqa
62-
exclude: docs/conf.py
63-
additional_dependencies: &flake8_dependencies
64-
- flake8-bugbear
65-
- flake8-print
62+
- repo: https://github.com/codespell-project/codespell
63+
rev: "v2.2.6"
64+
hooks:
65+
- id: codespell
6666

67-
- repo: https://github.com/pycqa/flake8
68-
rev: 6.0.0
69-
hooks:
70-
- id: flake8
71-
exclude: docs/conf.py
72-
additional_dependencies: *flake8_dependencies
67+
- repo: https://github.com/shellcheck-py/shellcheck-py
68+
rev: "v0.9.0.6"
69+
hooks:
70+
- id: shellcheck
7371

74-
# - repo: https://github.com/pre-commit/mirrors-mypy
75-
# rev: v0.930
76-
# hooks:
77-
# - id: mypy
78-
# files: src
79-
# args: [--show-error-codes]
72+
- repo: local
73+
hooks:
74+
- id: disallow-caps
75+
name: Disallow improper capitalization
76+
language: pygrep
77+
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
78+
exclude: .pre-commit-config.yaml
8079

81-
- repo: https://github.com/codespell-project/codespell
82-
rev: v2.2.2
83-
hooks:
84-
- id: codespell
80+
- repo: https://github.com/abravalheri/validate-pyproject
81+
rev: "v0.16"
82+
hooks:
83+
- id: validate-pyproject
84+
additional_dependencies: ["validate-pyproject-schema-store[all]"]
8585

86-
- repo: https://github.com/shellcheck-py/shellcheck-py
87-
rev: v0.9.0.2
88-
hooks:
89-
- id: shellcheck
90-
91-
- repo: local
92-
hooks:
93-
- id: disallow-caps
94-
name: Disallow improper capitalization
95-
language: pygrep
96-
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
97-
exclude: .pre-commit-config.yaml
86+
- repo: https://github.com/python-jsonschema/check-jsonschema
87+
rev: "0.28.0"
88+
hooks:
89+
- id: check-dependabot
90+
- id: check-github-workflows
91+
- id: check-readthedocs

.readthedocs.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ sphinx:
1313
formats: []
1414

1515
build:
16-
os: ubuntu-20.04
16+
os: ubuntu-22.04
1717
tools:
18-
python: "3.8"
18+
python: "3.11"
1919

2020
python:
2121
install:
22-
- method: pip
23-
path: .
24-
extra_requirements:
25-
- docs
26-
- dsecs_cp38_manylinux
22+
- method: pip
23+
path: .
24+
extra_requirements:
25+
- docs
26+
- dsecs_cp311_manylinux

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
[![GitHub Discussion][github-discussions-badge]][github-discussions-link]
1010

1111
[![Actions Status][actions-badge]][actions-link]
12-
[![Code style: black][black-badge]][black-link]
1312
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
13+
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json)](https://github.com/astral-sh/ruff)
1414

1515
---
1616

@@ -30,7 +30,7 @@
3030
[rtd-badge]: https://img.shields.io/badge/docs-online-success
3131
[rtd-link]: https://swarmpal.readthedocs.io/
3232

33-
![SwarmPAL diagram](https://swarmpal-benchmarks.netlify.app/swarmpal-diagram.png)
33+
![SwarmPAL diagram](https://swarmdisc.org/wp-content/uploads/2024/02/SwarmPAL-diagrams-overview.png)
3434

3535
For more information see:
3636
- <https://swarmdisc.org/lab/>

0 commit comments

Comments
 (0)