-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds a pre-commit hook to run on each commit, that will automatically run code linters and not allow you to commit changes if the linters fail. This is similar to how cudf uses pre-commit, as described in rapidsai/cudf#9309 . The pre-commit checks will also be run in CI as part of the check style script. This change also adds several new linters that weren't being run in CI before: * pydocstyle * mypy * black * isort * cmake-format * cmake-lint Of these new linters - mypy caught an issue where the test_comms.py would always be skipped (`python/raft-dask/raft_dask/test/test_comms.py:23: error: Module "raft_dask" has no attribute "Comms"` ), and Pydocstyle caught some minor formatting inconsistencies in the python docstrings. black/isort ensure consistent code formatting for the python raft code Authors: - Ben Frederickson (https://github.com/benfred) Approvers: - Micka (https://github.com/lowener) - Corey J. Nolet (https://github.com/cjnolet) - Ray Douglass (https://github.com/raydouglass) - Bradley Dice (https://github.com/bdice) URL: #965
- Loading branch information
Showing
62 changed files
with
1,835 additions
and
1,372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
|
||
repos: | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
# Use the config file specific to each subproject so that each | ||
# project can specify its own first/third-party packages. | ||
args: ["--config-root=python/", "--resolve-all-configs"] | ||
files: python/.* | ||
types_or: [python, cython, pyi] | ||
- repo: https://github.com/psf/black | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
files: python/.* | ||
# Explicitly specify the pyproject.toml at the repo root, not per-project. | ||
args: ["--config", "pyproject.toml"] | ||
exclude: .*_version.py,.*versioneer.py | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 5.0.4 | ||
hooks: | ||
- id: flake8 | ||
args: ["--config=setup.cfg"] | ||
files: python/.*$ | ||
types: [file] | ||
types_or: [python, cython] | ||
additional_dependencies: ["flake8-force"] | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: 'v0.971' | ||
hooks: | ||
- id: mypy | ||
additional_dependencies: [types-cachetools] | ||
args: ["--config-file=setup.cfg", | ||
"python/pylibraft/pylibraft", | ||
"python/raft-dask/raft_dask"] | ||
pass_filenames: false | ||
exclude: .*_version.py | ||
- repo: https://github.com/PyCQA/pydocstyle | ||
rev: 6.1.1 | ||
hooks: | ||
- id: pydocstyle | ||
args: ["--config=setup.cfg"] | ||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v11.1.0 | ||
hooks: | ||
- id: clang-format | ||
types_or: [c, c++, cuda] | ||
args: ["-fallback-style=none", "-style=file", "-i"] | ||
exclude: cpp/include/raft/thirdparty/.* | ||
- repo: local | ||
hooks: | ||
- id: no-deprecationwarning | ||
name: no-deprecationwarning | ||
description: 'Enforce that DeprecationWarning is not introduced (use FutureWarning instead)' | ||
entry: '(category=|\s)DeprecationWarning[,)]' | ||
language: pygrep | ||
types_or: [python, cython] | ||
- id: cmake-format | ||
name: cmake-format | ||
entry: ./cpp/scripts/run-cmake-format.sh cmake-format | ||
language: python | ||
types: [cmake] | ||
exclude: .*/thirdparty/.* | ||
# 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 | ||
verbose: true | ||
require_serial: true | ||
- id: cmake-lint | ||
name: cmake-lint | ||
entry: ./cpp/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 | ||
verbose: true | ||
require_serial: true | ||
exclude: .*/thirdparty/.* | ||
- id: copyright-check | ||
name: copyright-check | ||
entry: python ./ci/checks/copyright.py --git-modified-only --update-current-year | ||
language: python | ||
pass_filenames: false | ||
additional_dependencies: [gitpython] | ||
- id: include-check | ||
name: include-check | ||
entry: python ./cpp/scripts/include_checker.py cpp/bench cpp/include cpp/test | ||
pass_filenames: false | ||
language: python | ||
additional_dependencies: [gitpython] | ||
|
||
default_language_version: | ||
python: python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.