From 2cae4fd33e2ddcd4899ec45eb364e9466511ad39 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 21 Nov 2024 12:24:13 -0600 Subject: [PATCH] Add pre-commit hook to disallow improper comparison to `_nxver` (#22) `_nxver` was updated to either be a 2-tuple or 3-tuple in https://github.com/rapidsai/nx-cugraph/pull/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: https://github.com/rapidsai/nx-cugraph/pull/22 --- .pre-commit-config.yaml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e98b01fbb..07ea842fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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] @@ -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 @@ -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: