Skip to content

Commit

Permalink
Add pre-commit hook to disallow improper comparison to _nxver (#22)
Browse files Browse the repository at this point in the history
`_nxver` was updated to either be a 2-tuple or 3-tuple in #15, and we needed to update some comparisons to properly handle nx 3.4.1 and nx 3.4.2. The new pre-commit enforces sane comparisons when using `_nxver`.

Authors:
  - Erik Welch (https://github.com/eriknw)
  - Rick Ratzel (https://github.com/rlratzel)

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)
  - Jake Awe (https://github.com/AyodeAwe)
  - Kyle Edwards (https://github.com/KyleFromNVIDIA)

URL: #22
  • Loading branch information
eriknw authored Nov 21, 2024
1 parent 0248700 commit 2cae4fd
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.22
rev: v0.23
hooks:
- id: validate-pyproject
name: Validate pyproject.toml
Expand All @@ -51,7 +51,7 @@ repos:
- id: black
# - id: black-jupyter # Consider adding this
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.7.4
hooks:
- id: ruff
args: [--fix-only, --show-fixes] # --unsafe-fixes]
Expand Down Expand Up @@ -79,7 +79,7 @@ repos:
files: ^(nx_cugraph|docs)/
args: ["-L thirdparty,coo,COO,numer"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.7.4
hooks:
- id: ruff
# Don't have strict linting for miscellaneous code
Expand Down Expand Up @@ -109,6 +109,17 @@ repos:
language: python
pass_filenames: false
additional_dependencies: ["networkx>=3.4"]
- repo: local
hooks:
- id: disallow-improper-nxver-comparison
name: disallow improper comparison to `_nxver`
language: pygrep
# We expect bug-fix releases to be the same, so these rules avoid cases like:
# >>> (X, Y, 1) <= (X, Y)
# False
entry: "_nxver > |_nxver <= | < _nxver| >= _nxver"
# Use e.g. `_nxver < ...` or `_nxver >= ...` instead
exclude: .pre-commit-config.yaml
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.0
hooks:
Expand Down

0 comments on commit 2cae4fd

Please sign in to comment.