Skip to content

Commit 60f34a1

Browse files
committed
add pre-commit to the project
1 parent c974245 commit 60f34a1

31 files changed

Lines changed: 2513 additions & 1483 deletions

.flake8

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[flake8]
2+
extend-ignore =
3+
# whitespace before ':' (currently conflicts with black formatting):
4+
E203,
5+
# ‘from module import *’ used; unable to detect undefined names:
6+
F403,
7+
# missing docstring in public module:
8+
D100,
9+
# missing docstring in public class:
10+
D101,
11+
# missing docstring in public method:
12+
D102,
13+
# missing docstring in public function:
14+
D103,
15+
# missing docstring in __init__:
16+
D107,
17+
# 1 blank line required between summary line and description:
18+
D205,
19+
# first line should end with a period:
20+
D400,
21+
# first line should be in imperative mood:
22+
D401,
23+
24+
per-file-ignores =
25+
mkl_umath/__init__.py: F401
26+
mkl_umath/ufunc_docstrings_numpy1.py: E501
27+
mkl_umath/ufunc_docstrings_numpy2.py: E501
28+
29+
exclude = _vendored/conv_template.py
30+
31+
filename = *.py, *.pyx, *.pxi, *.pxd
32+
max_line_length = 80
33+
max-doc-length = 80
34+
show-source = True
35+
36+
# Print detailed statistic if any issue detected
37+
count = True
38+
statistics = True

.github/workflows/build-with-clang.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
run: |
7575
source ${{ env.ONEAPI_ROOT }}/setvars.sh
7676
pip install pytest
77-
# mkl_umath cannot be installed in editable mode, we need
77+
# mkl_umath cannot be installed in editable mode, we need
7878
# to change directory before importing it and running tests
7979
cd ..
8080
python -m pytest -sv --pyargs mkl_umath/mkl_umath/tests

.github/workflows/build_pip.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
CC=icx pip install . --no-build-isolation --no-deps --verbose
5656
pip install --no-cache-dir pytest
5757
pip list
58-
# mkl_umath cannot be installed in editable mode, we need
58+
# mkl_umath cannot be installed in editable mode, we need
5959
# to change directory before importing it and running tests
6060
cd ..
6161
python -m pytest -v mkl_umath/mkl_umath/tests

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ jobs:
319319
shell: cmd /C CALL {0}
320320
run: |
321321
conda activate
322-
echo "Value of CONDA enviroment variable was: " %CONDA%
323-
echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX%
322+
echo "Value of CONDA environment variable was: " %CONDA%
323+
echo "Value of CONDA_PREFIX environment variable was: " %CONDA_PREFIX%
324324
conda info && conda list -n mkl_umath_test
325325
326326
- name: Smoke test

.pre-commit-config.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-ast
6+
- id: check-builtin-literals
7+
- id: check-case-conflict
8+
- id: check-executables-have-shebangs
9+
- id: check-merge-conflict
10+
- id: check-toml
11+
- id: debug-statements
12+
- id: destroyed-symlinks
13+
- id: end-of-file-fixer
14+
- id: fix-byte-order-marker
15+
- id: mixed-line-ending
16+
- id: trailing-whitespace
17+
18+
- repo: https://github.com/pre-commit/pygrep-hooks
19+
rev: v1.10.0
20+
hooks:
21+
- id: python-check-blanket-noqa
22+
- id: python-check-blanket-type-ignore
23+
- id: python-check-mock-methods
24+
- id: python-no-eval
25+
- id: python-no-log-warn
26+
- id: python-use-type-annotations
27+
- id: rst-backticks
28+
- id: rst-directive-colons
29+
- id: rst-inline-touching-normal
30+
- id: text-unicode-replacement-char
31+
32+
- repo: https://github.com/codespell-project/codespell
33+
rev: v2.4.1
34+
hooks:
35+
- id: codespell
36+
args: ["-L", "nin,inout"]
37+
additional_dependencies:
38+
- tomli
39+
40+
- repo: https://github.com/psf/black
41+
rev: 26.1.0
42+
hooks:
43+
- id: black
44+
exclude: "_vendored/conv_template.py"
45+
46+
- repo: https://github.com/pocc/pre-commit-hooks
47+
rev: v1.3.5
48+
hooks:
49+
- id: clang-format
50+
args: ["-i"]
51+
52+
- repo: https://github.com/MarcoGorelli/cython-lint
53+
rev: v0.19.0
54+
hooks:
55+
- id: cython-lint
56+
- id: double-quote-cython-strings
57+
58+
- repo: https://github.com/pycqa/flake8
59+
rev: 7.3.0
60+
hooks:
61+
- id: flake8
62+
args: ["--config=.flake8"]
63+
additional_dependencies:
64+
- flake8-docstrings==1.7.0
65+
- flake8-bugbear==25.11.29
66+
67+
- repo: https://github.com/pycqa/isort
68+
rev: 8.0.0
69+
hooks:
70+
- id: isort
71+
name: isort (python)
72+
- id: isort
73+
name: isort (cython)
74+
types: [cython]
75+
- id: isort
76+
name: isort (pyi)
77+
types: [pyi]
78+
79+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
80+
rev: v2.16.0
81+
hooks:
82+
- id: pretty-format-toml
83+
args: [--autofix]
84+
85+
- repo: local
86+
hooks:
87+
- id: pylint
88+
name: pylint
89+
entry: pylint
90+
language: system
91+
types: [python]
92+
require_serial: true
93+
args:
94+
[
95+
"-rn", # Only display messages
96+
"-sn", # Don't display the score
97+
"--errors-only",
98+
"--disable=import-error",
99+
]
100+
101+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
102+
rev: 3.0.0
103+
hooks:
104+
- id: shellcheck

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
* Enabled support of Python 3.13 [gh-101](https://github.com/IntelPython/mkl_umath/pull/101)
2525
* Added mkl implementation for complex data-types of `add`, `subtract`, `multiply` and `divide` functions [gh-102](https://github.com/IntelPython/mkl_umath/pull/102)
2626

27-
### Changed
27+
### Changed
2828
* Dropped support for `maximum` and `minimum` [gh-104](https://github.com/IntelPython/mkl_umath/pull/104)
2929
* Disabled `-fast-math` by default [gh-105](https://github.com/IntelPython/mkl_umath/pull/105)
3030
* Used a common umath loop for `log2` function to match NumPy [gh-109](https://github.com/IntelPython/mkl_umath/pull/109)
@@ -37,7 +37,7 @@ This release updates `mkl_umath` to be aligned with both numpy-1.26.x and numpy-
3737
* The definition of `sign` function for complex floating point data types is updated to match numpy-2.x.x [gh-65](https://github.com/IntelPython/mkl_umath/pull/65)
3838
* `ldexp` function is updated to allow `int64` explicitly similar to numpy-2.x.x behavior [gh-73](https://github.com/IntelPython/mkl_umath/pull/73)
3939

40-
### Changed
40+
### Changed
4141
* Migrated from `setup.py` to `pyproject toml` [gh-63](https://github.com/IntelPython/mkl_umath/pull/63)
4242
* Changed to dynamic linking and added interface and threading layers [gh-72](https://github.com/IntelPython/mkl_umath/pull/72)
4343

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ powered version of loops used in the patched version of [NumPy](https://numpy.or
99

1010
Patches were factored out per community feedback ([NEP-36](https://numpy.org/neps/nep-0036-fair-play.html)).
1111

12-
`mkl_umath` started as a part of Intel® Distribution for Python* optimizations to NumPy, and is now being released
12+
`mkl_umath` started as a part of Intel® Distribution for Python* optimizations to NumPy, and is now being released
1313
as a stand-alone package. It can be installed into conda environment using:
1414

1515
```

_vendored/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
File `conv_template.py` is copied from NumPy's numpy/distutils folder, since
44
`numpy.distutils` is absent from the installation layout starting with
5-
Python 3.12
5+
Python 3.12

conda-recipe-cf/build.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
#!/bin/bash
2+
13
# This is necessary to help DPC++ find Intel libraries such as SVML, IRNG, etc in build prefix
24
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${BUILD_PREFIX}/lib"
35

46
# Intel LLVM must cooperate with compiler and sysroot from conda
57
echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot -target ${HOST}" > icx_for_conda.cfg
6-
export ICXCFG="$(pwd)/icx_for_conda.cfg"
8+
ICXCFG="$(pwd)/icx_for_conda.cfg"
9+
export ICXCFG
710

811
read -r GLIBC_MAJOR GLIBC_MINOR <<< "$(conda list '^sysroot_linux-64$' \
912
| tail -n 1 | awk '{print $2}' | grep -oP '\d+' | head -n 2 | tr '\n' ' ')"
@@ -14,9 +17,9 @@ SKBUILD_ARGS="-- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
1417
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
1518
# Install packages and assemble wheel package from built bits
1619
WHEELS_BUILD_ARGS="-p manylinux_${GLIBC_MAJOR}_${GLIBC_MINOR}_x86_64"
17-
${PYTHON} setup.py install bdist_wheel ${WHEELS_BUILD_ARGS} ${SKBUILD_ARGS}
18-
cp dist/mkl_umath*.whl ${WHEELS_OUTPUT_FOLDER}
20+
${PYTHON} setup.py install bdist_wheel "${WHEELS_BUILD_ARGS}" "${SKBUILD_ARGS}"
21+
cp dist/mkl_umath*.whl "${WHEELS_OUTPUT_FOLDER}"
1922
else
2023
# Perform regular install
21-
${PYTHON} setup.py install ${SKBUILD_ARGS}
24+
${PYTHON} setup.py install "${SKBUILD_ARGS}"
2225
fi

conda-recipe-cf/run_tests.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
%PYTHON% tests\test_basic.py
1+
%PYTHON% tests\test_basic.py

0 commit comments

Comments
 (0)