Skip to content

Commit

Permalink
enable nbqa pre-commit hook (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle authored Jul 17, 2024
1 parent 2aff393 commit c51459a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 55 deletions.
115 changes: 63 additions & 52 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,22 @@ ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.18"
hooks:
- id: validate-pyproject

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.18.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==24.*]

- repo: https://github.com/aio-libs/sort-all
rev: "v1.2.0"
hooks:
- id: check-added-large-files
exclude: "tests/plotting/image_cache"
# Prevent giant files from being committed.
- id: check-ast
# Check whether files parse as valid Python.
- id: check-case-conflict
# Check for file name conflicts on case-insensitive file-systems.
- id: check-merge-conflict
# Check for files that contain merge conflict strings.
- id: debug-statements
# Check for debugger imports and py37+ `breakpoint()` calls in Python source.
- id: check-toml
# Check TOML file syntax.
- id: check-yaml
# Check YAML file syntax.
- id: end-of-file-fixer
# Makes sure files end in a newline and only a newline.
exclude_types: [svg]
- id: mixed-line-ending
# Replaces or checks mixed line ending.
- id: no-commit-to-branch
# Don't commit to main branch.
- id: trailing-whitespace
# Trims trailing whitespace.
- id: sort-all
types: [file, python]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.5.2"
Expand All @@ -48,15 +37,56 @@ repos:
- repo: https://github.com/codespell-project/codespell
rev: "v2.3.0"
hooks:
- id: codespell
types_or: [python, markdown, rst]
additional_dependencies: [tomli]
- id: codespell
types_or: [python, markdown, rst]
additional_dependencies: [tomli]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.18.0"
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.5
hooks:
- id: blacken-docs
additional_dependencies: [black==24.*]
- id: nbqa-ruff
name: nbqa-ruff
entry: ruff check
language: python
additional_dependencies: [ruff]
require_serial: true
types_or: [jupyter]

- repo: https://github.com/numpy/numpydoc
rev: v1.7.0
hooks:
- id: numpydoc-validation
files: "^src/"
exclude: "^src/geovista/examples/"
types: [file, python]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
hooks:
- id: check-added-large-files
exclude: "tests/plotting/image_cache"
# Prevent giant files from being committed.
- id: check-ast
# Check whether files parse as valid Python.
- id: check-case-conflict
# Check for file name conflicts on case-insensitive file-systems.
- id: check-merge-conflict
# Check for files that contain merge conflict strings.
- id: debug-statements
# Check for debugger imports and py37+ `breakpoint()` calls in Python source.
- id: check-toml
# Check TOML file syntax.
- id: check-yaml
# Check YAML file syntax.
- id: end-of-file-fixer
# Makes sure files end in a newline and only a newline.
exclude_types: [svg]
- id: mixed-line-ending
# Replaces or checks mixed line ending.
- id: no-commit-to-branch
# Don't commit to main branch.
- id: trailing-whitespace
# Trims trailing whitespace.

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
Expand All @@ -77,17 +107,6 @@ repos:
- id: text-unicode-replacement-char
# Forbid files which have a UTF-8 Unicode replacement character.

- repo: https://github.com/aio-libs/sort-all
rev: "v1.2.0"
hooks:
- id: sort-all
types: [file, python]

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.18"
hooks:
- id: validate-pyproject

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.0
hooks:
Expand All @@ -101,11 +120,3 @@ repos:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
args: ["--show=errskip"]

- repo: https://github.com/numpy/numpydoc
rev: v1.7.0
hooks:
- id: numpydoc-validation
files: "^src/"
exclude: "^src/geovista/examples/"
types: [file, python]
9 changes: 6 additions & 3 deletions docs/src/tutorials/region-manifold-extraction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@
"# i.e., \"tags\": [ \"remove-cell\" ]\n",
"#\n",
"\n",
"from __future__ import annotations\n",
"\n",
"import pyvista\n",
"\n",
"import geovista.cache\n",
"import geovista.theme\n",
"import pyvista\n",
"\n",
"# Tip: Change this to \"trame\" for an interactive backend.\n",
"pyvista.set_jupyter_backend(\"static\")\n",
Expand Down Expand Up @@ -112,7 +115,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "dbd25452-a737-45df-b38f-aa3cc027d843",
"id": "19c5fbb7-61fe-43c8-9e06-d61695455e2c",
"metadata": {
"editable": true,
"slideshow": {
Expand Down Expand Up @@ -697,7 +700,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ ignore-words-list = "whet,projets"
skip = ".git,*.ipynb,*.rst,CODE_OF_CONDUCT.md"


[tool.nbqa.addopts]
"ruff check" = [
"--ignore=D100,E402,INP001",
]
[tool.nbqa.files]
"ruff check" = "docs/src/tutorials/"


[tool.numpydoc_validation]
checks = [
"all", # Enable all numpydoc validation rules, apart from the following:
Expand Down

0 comments on commit c51459a

Please sign in to comment.