Skip to content

Commit

Permalink
Update .pre-commit-config.yaml template to best practices from acro…
Browse files Browse the repository at this point in the history
…ss SciTools repos (#26)

* Readability improvements.

* Updates from SciTools/iris#5937 .

* Updates from SciTools/workflows#50 .

* Updates from SciTools/mo_pack#34 .

* Updates from SciTools/iris-grib#464 .

* Other updates.
  • Loading branch information
trexfeathers committed May 31, 2024
1 parent 4f50f39 commit 6cd87da
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/template-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
Bot
Type: Infrastructure
COMMIT_PREFIX: "👁 TEMPLATE DEVIATIONS:"
PR_BODY: "## Please read: https://github.com/SciTools/.github/tree/main/templates"
PR_BODY: "# [Click for `README`](https://github.com/SciTools/.github/tree/main/templates)"
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ Organisational level things such as the SciTools README and organisation workflo
- [`./peloton`](./peloton) - contains the scripts for automating population of the
[SciTools Peloton project](https://github.com/orgs/SciTools/projects/13?pane=info).
See also [`.github/workflows/peloton.yml`](.github/workflows/peloton.yml).
- [`./templates`](./templates) - tooling for standardising files across
SciTools repos. See also
[`.github/workflows/template-sync.yml`](.github/workflows/template-sync.yml).

## Possible uses
## Possible future uses

- [An organizational README](https://docs.github.com/en/organizations/collaborating-with-groups-in-organizations/customizing-your-organizations-profile#adding-a-public-organization-profile-readme)
- Workflows for managing organization-level projects
E.g. [Peloton](./peloton)
- Automation for comparing SciTools repos
E.g. linting config, benchmark setup etc.
60 changes: 48 additions & 12 deletions templates/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# See https://pre-commit.ci/#configuration
# See https://github.com/scientific-python/cookie#sp-repo-review

ci:
autofix_prs: false
autoupdate_commit_msg: "chore: update pre-commit hooks"


# Alphabetised, for lack of a better order.
files: |
(?x)(
benchmarks\/.+\.py|
docs\/.+\.py|
lib\/.+\.py|
noxfile\.py|
pyproject\.toml|
setup\.py|
docs\/.+\.py|
benchmarks\/.+\.py|
src\/.+\.py
)
minimum_pre_commit_version: 1.21.0

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
# Prevent giant files from being committed.
- id: check-added-large-files
# Check whether files parse as valid Python.
- id: check-ast
# Check for file name conflicts on case-insensitive filesytems.
# Check for file name conflicts on case-insensitive filesystems.
- id: check-case-conflict
# Check for files that contain merge conflict strings.
- id: check-merge-conflict
# Check for debugger imports and py37+ `breakpoint()` calls in Python source.
- id: debug-statements
# Check TOML file syntax.
- id: check-toml
# Check YAML file syntax.
- id: check-yaml
# Makes sure files end in a newline and only a newline.
# Duplicates Ruff W292 but also works on non-Python files.
- id: end-of-file-fixer
# Replaces or checks mixed line ending.
- id: mixed-line-ending
# Don't commit to main branch.
- id: no-commit-to-branch
# Trims trailing whitespace.
# Duplicates Ruff W291 but also works on non-Python files.
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.4"
rev: "v0.4.4"
hooks:
- id: ruff
types: [file, python]
Expand All @@ -43,13 +66,7 @@ repos:
types_or: [asciidoc, python, markdown, rst]
additional_dependencies: [tomli]

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
types: [file, python]

- repo: https://github.com/asottile/blacken-docs
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
Expand All @@ -61,6 +78,25 @@ repos:
- id: sort-all
types: [file, python]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.10.0'
hooks:
- id: mypy
exclude: 'noxfile\.py|docs/conf\.py'

- repo: https://github.com/abravalheri/validate-pyproject
# More exhaustive than Ruff RUF200.
rev: "v0.18"
hooks:
- id: validate-pyproject

- repo: https://github.com/scientific-python/cookie
rev: 2024.04.23
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
args: ["--show=errskip"]

- repo: https://github.com/numpy/numpydoc
rev: v1.7.0
hooks:
Expand Down

0 comments on commit 6cd87da

Please sign in to comment.