From 09f7f627b34721578ced7a0324654867af20b9a0 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 9 Dec 2024 09:43:27 -0600 Subject: [PATCH] Add configuration for pre-commit.ci, update pre-commit hooks (#1746) This PR adds configuration for pre-commit.ci, reformats the pre-commit config file, and updates pre-commit hooks. See https://github.com/rapidsai/build-planning/issues/124 for the motivation. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ray Douglass (https://github.com/raydouglass) - Matthew Murray (https://github.com/Matt711) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1746 --- .pre-commit-config.yaml | 185 +++++++++++++++++++++------------------- pyproject.toml | 4 +- python/rmm/docs/conf.py | 2 +- 3 files changed, 101 insertions(+), 90 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 56c972b4e..2f8385092 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,91 +1,100 @@ -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. +ci: + autofix_commit_msg: "[pre-commit.ci] auto code formatting" + autofix_prs: false + autoupdate_branch: "" + autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" + autoupdate_schedule: quarterly + skip: ["verify-alpha-spec"] + submodules: false + repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - args: ["--settings-path=python/rmm/pyproject.toml"] - files: python/.* - types_or: [python, cython, pyi] - - repo: https://github.com/ambv/black - rev: 22.3.0 - hooks: - - id: black - args: ["--config=python/rmm/pyproject.toml"] - - repo: https://github.com/MarcoGorelli/cython-lint - rev: v0.15.0 - hooks: - - id: cython-lint - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v16.0.6 - hooks: - - id: clang-format - types_or: [c, c++, cuda] - args: ["-fallback-style=none", "-style=file", "-i"] - - repo: https://github.com/sirosen/texthooks - rev: 0.4.0 - hooks: - - id: fix-smartquotes - exclude: | - (?x)^( - ^benchmarks/utilities/cxxopts.hpp - ) - - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 - hooks: - - id: codespell - exclude: | - (?x)^( - pyproject.toml| - benchmarks/utilities/cxxopts.hpp - ) - - repo: local - hooks: - - id: cmake-format - name: cmake-format - entry: ./scripts/run-cmake-format.sh cmake-format - language: python - types: [cmake] - # Note that pre-commit autoupdate does not update the versions - # of dependencies, so we'll have to update this manually. - additional_dependencies: - - cmakelang==0.6.13 - - id: cmake-lint - name: cmake-lint - entry: ./scripts/run-cmake-format.sh cmake-lint - language: python - types: [cmake] - # Note that pre-commit autoupdate does not update the versions - # of dependencies, so we'll have to update this manually. - additional_dependencies: - - cmakelang==0.6.13 - - id: doxygen-check - name: doxygen-check - entry: ./scripts/doxygen.sh - types_or: [file] - language: system - pass_filenames: false - verbose: true - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.278 - hooks: - - id: ruff - files: python/.*$ - - repo: https://github.com/rapidsai/pre-commit-hooks - rev: v0.4.0 - hooks: - - id: verify-copyright - - id: verify-alpha-spec - - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.16.0 - hooks: - - id: rapids-dependency-file-generator - args: ["--clean"] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--settings-path=python/rmm/pyproject.toml"] + files: python/.* + types_or: [python, cython, pyi] + - repo: https://github.com/ambv/black + rev: 24.10.0 + hooks: + - id: black + args: ["--config=python/rmm/pyproject.toml"] + - repo: https://github.com/MarcoGorelli/cython-lint + rev: v0.16.6 + hooks: + - id: cython-lint + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v16.0.6 + hooks: + - id: clang-format + types_or: [c, c++, cuda] + args: ["-fallback-style=none", "-style=file", "-i"] + - repo: https://github.com/sirosen/texthooks + rev: 0.6.8 + hooks: + - id: fix-smartquotes + exclude: | + (?x)^( + ^benchmarks/utilities/cxxopts.hpp + ) + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + exclude: | + (?x)^( + pyproject.toml| + benchmarks/utilities/cxxopts.hpp + ) + - repo: local + hooks: + - id: cmake-format + name: cmake-format + entry: ./scripts/run-cmake-format.sh cmake-format + language: python + types: [cmake] + # Note that pre-commit autoupdate does not update the versions + # of dependencies, so we'll have to update this manually. + additional_dependencies: + - cmakelang==0.6.13 + - id: cmake-lint + name: cmake-lint + entry: ./scripts/run-cmake-format.sh cmake-lint + language: python + types: [cmake] + # Note that pre-commit autoupdate does not update the versions + # of dependencies, so we'll have to update this manually. + additional_dependencies: + - cmakelang==0.6.13 + - id: doxygen-check + name: doxygen-check + entry: ./scripts/doxygen.sh + types_or: [file] + language: system + pass_filenames: false + verbose: true + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.2 + hooks: + - id: ruff + files: python/.*$ + - repo: https://github.com/rapidsai/pre-commit-hooks + rev: v0.4.0 + hooks: + - id: verify-copyright + - id: verify-alpha-spec + - repo: https://github.com/rapidsai/dependency-file-generator + rev: v1.16.0 + hooks: + - id: rapids-dependency-file-generator + args: ["--clean"] default_language_version: - python: python3 + python: python3 diff --git a/pyproject.toml b/pyproject.toml index 285098f99..929d5e563 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,12 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. + [tool.codespell] # note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - # this is only to allow you to run codespell interactively skip = "./pyproject.toml,./.git,./.github,./cpp/build,.*egg-info.*,./.mypy_cache,./benchmarks/utilities/cxxopts.hpp" # ignore short words, and typename parameters like OffsetT ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b" -ignore-words-list = "inout" +ignore-words-list = "inout,thirdparty" builtin = "clear" quiet-level = 3 diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index 99242daa5..a21698ded 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -278,7 +278,7 @@ def on_missing_reference(app, env, node, contnode): # all that's missing. Include the empty prefix in case we're searching # for a stripped template. extra_prefixes = ["rmm::", "rmm::mr::", "mr::", ""] - for (name, dispname, typ, docname, anchor, priority) in env.domains[ + for name, dispname, typ, docname, anchor, priority in env.domains[ "cpp" ].get_objects(): for prefix in extra_prefixes: