Skip to content

Extend pre-commit hooks with pretty-format-toml #2399

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

Merged
merged 3 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/PyCQA/bandit
rev: '1.7.9'
rev: '1.8.3'
hooks:
- id: bandit
pass_filenames: false
args: ["-r", "dpnp", "-lll"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-ast
- id: check-builtin-literals
Expand Down Expand Up @@ -44,17 +44,18 @@ repos:
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
args: ["-L", "abd"] # ignore "abd" used in einsum tests
additional_dependencies:
- tomli
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 25.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 6.0.1
hooks:
- id: isort
name: isort (python)
Expand All @@ -65,20 +66,20 @@ repos:
name: isort (pyi)
types: [pyi]
- repo: https://github.com/pycqa/flake8
rev: 7.1.0
rev: 7.1.2
hooks:
- id: flake8
args: ["--config=.flake8"]
additional_dependencies:
- flake8-docstrings==1.7.0
- flake8-bugbear==24.4.26
- flake8-bugbear==24.12.12
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
args: ["-i"]
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.4
rev: v8.24.0
hooks:
- id: gitleaks
- repo: https://github.com/jumanjihouse/pre-commit-hooks
Expand All @@ -102,3 +103,8 @@ repos:
"--disable=unused-wildcard-import"
]
files: '^dpnp/(dpnp_iface.*|fft|linalg)'
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-toml
args: [--autofix]
2 changes: 1 addition & 1 deletion dpnp/dpnp_iface_linearalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def einsum(
>>> a = np.ones(64000).reshape(20, 40, 80)

Basic `einsum`: 119 ms ± 26 ms per loop (evaluated on 12th
Gen Intel\u00AE Core\u2122 i7 processor)
Gen Intel\u00ae Core\u2122 i7 processor)

>>> %timeit np.einsum("ijk,ilm,njm,nlk,abc->",a, a, a, a, a)

Expand Down
2 changes: 1 addition & 1 deletion dpnp/tests/third_party/cupy/math_tests/test_sumprod.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def test_cub_cumprod(self, xp, dtype):
return self._mitigate_cumprod(xp, dtype, result)

def _mitigate_cumprod(self, xp, dtype, result):
# for testing cumprod against complex arrays, the gotcha is CuPy may
# for testing cumprod against complex arrays, the catch is CuPy may
# produce only Inf at the position where NumPy starts to give NaN. So,
# an error would be raised during assert_allclose where the positions
# of NaNs are examined. Since this is both algorithm and architecture
Expand Down
8 changes: 4 additions & 4 deletions dpnp/tests/third_party/intel/zero-copy-test1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def __init__(self, shape, dtype="d", host_buffer=None):
shmem.copy_from_host(host_buffer.view(dtype="|u1"))
self.arr = np.ndarray(shape, dtype=dtype, buffer=shmem)

def __getitem__(self, indx):
return self.arr[indx]
def __getitem__(self, index):
return self.arr[index]

def __setitem__(self, indx, val):
self.arr.__setitem__(indx, val)
def __setitem__(self, index, val):
self.arr.__setitem__(index, val)

@property
def __sycl_usm_array_interface__(self):
Expand Down
6 changes: 5 additions & 1 deletion dpnp/to_numba/dpnp_iface_to_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
import numba
from numba.extending import get_cython_function_address as nba_addr

name_to_numba_signatures = {"cos": [(numba.types.float64)]}
name_to_numba_signatures = {
"cos": [
(numba.types.float64),
]
}

name_and_types_to_pointer = {
("cos", numba.types.float64): ctypes.CFUNCTYPE(
Expand Down
92 changes: 48 additions & 44 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,38 @@ target-version = ['py38', 'py39', 'py310']
[tool.codespell]
builtin = "clear,rare,informal,names"
check-filenames = true
ignore-words-list="amin,arange,elemt,fro,hist,ith,mone,nd,nin,sinc,vart"
ignore-words-list = "amin,arange,elemt,fro,hist,ith,mone,nd,nin,sinc,vart"
quiet-level = 3

[tool.coverage.report]
omit = [
"dpnp/tests/*",
"dpnp/_version.py"
]

[tool.coverage.run]
branch = true
omit = [
"dpnp/tests/*",
"dpnp/_version.py"
]
plugins = [
"Cython.Coverage"
]
source = [
"dpnp"
]

[tool.isort]
ensure_newline_before_comments = true
force_grid_wrap = 0
include_trailing_comma = true
line_length = 80
multi_line_output = 3
skip = ["dpnp/__init__.py"]
split_on_trailing_comma = true
use_parentheses = true

[tool.pylint.basic]
include-naming-hint = true

Expand All @@ -16,9 +45,9 @@ exclude-protected = ["_create_from_usm_ndarray"]

[tool.pylint.design]
max-args = 11
max-positional-arguments = 9
max-locals = 30
max-branches = 16
max-locals = 30
max-positional-arguments = 9
max-returns = 8

[tool.pylint.format]
Expand All @@ -31,47 +60,22 @@ allow-wildcard-with-all = true
[tool.pylint.miscellaneous]
notes = ["FIXME", "XXX"]

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 80
split_on_trailing_comma = true
skip = ["dpnp/__init__.py"]

[tool.coverage.run]
plugins = [
"Cython.Coverage"
]
branch = true
source = [
"dpnp",
]
omit = [
"dpnp/tests/*",
"dpnp/_version.py",
]

[tool.coverage.report]
omit = [
"dpnp/tests/*",
"dpnp/_version.py",
]

[tool.pytest.ini.options]
minversion = "6.0"
norecursedirs= [
".*", "*.egg*", "build", "dist", "conda-recipe",
]
addopts = [
"--junitxml=junit.xml",
"--ignore setup.py",
"--ignore run_test.py",
"--cov-report term-missing",
"--tb native",
"--strict",
"--durations=20",
"-q -ra",
"--junitxml=junit.xml",
"--ignore setup.py",
"--ignore run_test.py",
"--cov-report term-missing",
"--tb native",
"--strict",
"--durations=20",
"-q -ra"
]
minversion = "6.0"
norecursedirs = [
".*",
"*.egg*",
"build",
"dist",
"conda-recipe"
]
Loading