-
Notifications
You must be signed in to change notification settings - Fork 14
[MAINT] Add pre commit hooks #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ndgrigorian
wants to merge
6
commits into
feature/add-numpy-random-interface
Choose a base branch
from
add-pre-commit-hooks
base: feature/add-numpy-random-interface
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,759
−3,184
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1982deb
add pre-commit hooks to the project
ndgrigorian d59e673
add linting changes to git-blame-ignore-revs
ndgrigorian 0bbf7ed
add pre-commit autoupdate workflow
ndgrigorian 651b4d2
update github actions in pre-commit autoupdate
ndgrigorian 1c72c54
use python 3.14 in pre-commit
ndgrigorian 47953a2
use python 3.14 in pre-commit update
ndgrigorian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,37 @@ | ||
| [flake8] | ||
| extend-ignore = | ||
| # whitespace before ':' (currently conflicts with black formatting): | ||
| E203, | ||
| # missing docstring in public module: | ||
| D100, | ||
| # missing docstring in public class: | ||
| D101, | ||
| # missing docstring in public method: | ||
| D103, | ||
| # missing docstring in public package: | ||
| D104, | ||
| # missing docstring in magic method: | ||
| D105, | ||
| # missing docstring in __init__: | ||
| D107, | ||
| # 1 blank line required between summary line and description: | ||
| D205, | ||
| # first line should end with a period: | ||
| D400, | ||
| # first line should be in imperative mood: | ||
| D401, | ||
| # first line should not be the function's "signature": | ||
| D402, | ||
|
|
||
| per-file-ignores = | ||
| mkl_random/__init__.py: F401 | ||
| mkl_random/interfaces/__init__.py: F401 | ||
|
|
||
| filename = *.py, *.pyx, *.pxi, *.pxd | ||
| max_line_length = 80 | ||
| max-doc-length = 80 | ||
| show-source = True | ||
|
|
||
| # Print detailed statistic if any issue detected | ||
| count = True | ||
| statistics = True |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,49 @@ | ||
| name: Autoupdate pre-commit | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| # To guarantee Maintained check is occasionally updated. See | ||
| # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained | ||
| schedule: | ||
| - cron: '28 2 * * 6' # Saturday at 02:28 UTC | ||
|
|
||
| permissions: read-all | ||
|
|
||
| jobs: | ||
| autoupdate: | ||
| name: Autoupdate | ||
|
|
||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
|
|
||
| permissions: | ||
| # Needed to create a PR with autoupdate changes | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Set up python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v5.6.0 | ||
| with: | ||
| python-version: '3.14' | ||
|
|
||
| - name: Install pre-commit | ||
| run: pip install pre-commit | ||
|
|
||
| - name: Run pre-commit autoupdate | ||
| run: pre-commit autoupdate | ||
|
|
||
| - name: Create a PR with autoupdate changes | ||
| uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 | ||
| with: | ||
| commit-message: 'chore: update pre-commit hooks' | ||
| add-paths: .pre-commit-config.yaml | ||
| branch: 'bot/pre-commit-autoupdate' | ||
| delete-branch: true | ||
| title: Weekly pre-commit autoupdate | ||
| body: | | ||
| This PR updates the `.pre-commit-config.yaml` using `pre-commit autoupdate`. | ||
| labels: autoupdate |
This file contains hidden or 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,31 @@ | ||
| name: pre-commit | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [master] | ||
|
|
||
| permissions: read-all | ||
|
|
||
| jobs: | ||
| pre-commit: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Set up python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: '3.14' | ||
|
|
||
| - name: Set up pip packages | ||
| uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 # v1 | ||
| with: | ||
| packages: | | ||
| codespell | ||
| pylint | ||
|
|
||
| - name: Run pre-commit checks | ||
| uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -8,4 +8,3 @@ __pycache__/ | |
| mkl_random/src/mklrand.c | ||
| mkl_random/mklrand.cpp | ||
| mkl_random/mklrand.cpython*.so | ||
|
|
||
This file contains hidden or 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,103 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: check-ast | ||
| - id: check-builtin-literals | ||
| - id: check-case-conflict | ||
| - id: check-executables-have-shebangs | ||
| - id: check-merge-conflict | ||
| - id: check-toml | ||
| - id: debug-statements | ||
| - id: destroyed-symlinks | ||
| - id: end-of-file-fixer | ||
| - id: fix-byte-order-marker | ||
| - id: mixed-line-ending | ||
| - id: trailing-whitespace | ||
|
|
||
| - repo: https://github.com/pre-commit/pygrep-hooks | ||
| rev: v1.10.0 | ||
| hooks: | ||
| - id: python-check-blanket-noqa | ||
| - id: python-check-blanket-type-ignore | ||
| - id: python-check-mock-methods | ||
| - id: python-no-eval | ||
| - id: python-no-log-warn | ||
| - id: python-use-type-annotations | ||
| - id: rst-backticks | ||
| - id: rst-directive-colons | ||
| - id: rst-inline-touching-normal | ||
| - id: text-unicode-replacement-char | ||
|
|
||
| - repo: https://github.com/codespell-project/codespell | ||
| rev: v2.4.1 | ||
| hooks: | ||
| - id: codespell | ||
| args: ["-L", "nd,hart,elemente,wirth"] | ||
| additional_dependencies: | ||
| - tomli | ||
|
|
||
| - repo: https://github.com/psf/black | ||
| rev: 26.1.0 | ||
| hooks: | ||
| - id: black | ||
|
|
||
| - repo: https://github.com/pocc/pre-commit-hooks | ||
| rev: v1.3.5 | ||
| hooks: | ||
| - id: clang-format | ||
| args: ["-i"] | ||
|
|
||
| - repo: https://github.com/MarcoGorelli/cython-lint | ||
| rev: v0.19.0 | ||
| hooks: | ||
| - id: cython-lint | ||
| - id: double-quote-cython-strings | ||
|
|
||
| - repo: https://github.com/pycqa/flake8 | ||
| rev: 7.3.0 | ||
| hooks: | ||
| - id: flake8 | ||
| args: ["--config=.flake8"] | ||
| additional_dependencies: | ||
| - flake8-docstrings==1.7.0 | ||
| - flake8-bugbear==25.11.29 | ||
|
|
||
| - repo: https://github.com/pycqa/isort | ||
| rev: 8.0.0 | ||
| hooks: | ||
| - id: isort | ||
| name: isort (python) | ||
| - id: isort | ||
| name: isort (cython) | ||
| types: [cython] | ||
| - id: isort | ||
| name: isort (pyi) | ||
| types: [pyi] | ||
|
|
||
| - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks | ||
| rev: v2.16.0 | ||
| hooks: | ||
| - id: pretty-format-toml | ||
| args: [--autofix] | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: pylint | ||
| name: pylint | ||
| entry: pylint | ||
| language: system | ||
| types: [python] | ||
| require_serial: true | ||
| args: | ||
| [ | ||
| "-rn", # Only display messages | ||
| "-sn", # Don't display the score | ||
| "--errors-only", | ||
| "--disable=import-error", | ||
| ] | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is about? - repo: https://github.com/gitleaks/gitleaks
rev: v8.30.0
hooks:
- id: gitleaks
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and for GH actions: - repo: https://github.com/rhysd/actionlint
rev: v1.7.11
hooks:
- id: actionlint |
||
| - repo: https://github.com/jumanjihouse/pre-commit-hooks | ||
| rev: 3.0.0 | ||
| hooks: | ||
| - id: shellcheck | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think to extend with more ones, like dpnp has:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a bad idea, one thing I'm also considering is moving as much linting as possible across all of the projects to ruff
numpy uses it, and it could replace black, flake8, and isort at once, maybe one or two others
But this isn't necessarily incompatible with that, so I can add these