Skip to content

Commit e47438a

Browse files
authored
Merge pull request #94 from IntelPython/add-pre-commit-hooks
[MAINT] Add pre commit hooks
2 parents a949a2c + a338c4d commit e47438a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4844
-3245
lines changed

.flake8

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[flake8]
2+
extend-ignore =
3+
# whitespace before ':' (currently conflicts with black formatting):
4+
E203,
5+
# missing docstring in public module:
6+
D100,
7+
# missing docstring in public class:
8+
D101,
9+
# missing docstring in public method:
10+
D103,
11+
# missing docstring in public package:
12+
D104,
13+
# missing docstring in magic method:
14+
D105,
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+
# first line should not be the function's "signature":
24+
D402,
25+
26+
per-file-ignores =
27+
mkl_random/__init__.py: F401
28+
mkl_random/interfaces/__init__.py: F401
29+
30+
filename = *.py, *.pyx, *.pxi, *.pxd
31+
max_line_length = 80
32+
max-doc-length = 80
33+
show-source = True
34+
35+
# Print detailed statistic if any issue detected
36+
count = True
37+
statistics = True

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22

33
# Sporadic fixes in test_random.py
44
e76aa3a5a4b889c0434f0103ec102a50b93ab1ca
5+
6+
# Added pre-commit hooks
7+
6b744ed48c680cd9592819a7febce8610434b0f3
8+
9+
# Added more pre-commit hooks
10+
c52e36d98bbe4b0318d537088eb4f7495278f7bb

.github/workflows/build-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
run: |
5454
# Ensure that SYCL libraries are on LD_LIBRARY_PATH
5555
source /opt/intel/oneapi/setvars.sh
56-
pip install --no-deps --no-build-isolation -e . --verbose
56+
pip install --no-deps --no-build-isolation -e . --verbose
5757
python -c "import mkl_random; print(mkl_random.__version__)" || exit 1
5858
sphinx-build -M html docs/source docs/build
5959
mkdir -p ~/rendered_docs

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
16-
numpy_version: ["numpy'>=2'"]
16+
numpy_version: ["numpy>=2"]
1717
env:
1818
ONEAPI_ROOT: /opt/intel/oneapi
1919

@@ -55,22 +55,22 @@ jobs:
5555
- name: Install mkl_random dependencies
5656
run: |
5757
pip install cython setuptools">=77"
58-
pip install ${{ matrix.numpy_version }}
58+
pip install "${{ matrix.numpy_version }}"
5959
6060
- name: List oneAPI folder content
61-
run: ls ${{ env.ONEAPI_ROOT }}/compiler
61+
run: ls "${{ env.ONEAPI_ROOT }}/compiler"
6262

6363
- name: Build mkl_random
6464
run: |
65-
source ${{ env.ONEAPI_ROOT }}/setvars.sh
66-
echo $CMPLR_ROOT
67-
export CC=$CMPLR_ROOT/bin/icx
68-
export CXX=$CMPLR_ROOT/bin/icpx
65+
source "${{ env.ONEAPI_ROOT }}/setvars.sh"
66+
echo "$CMPLR_ROOT"
67+
export CC="$CMPLR_ROOT/bin/icx"
68+
export CXX="$CMPLR_ROOT/bin/icpx"
6969
export CFLAGS="${CFLAGS} -fno-fast-math -O2"
7070
pip install -e . --no-build-isolation --no-deps --verbose
7171
7272
- name: Run mkl_random tests
7373
run: |
74-
source ${{ env.ONEAPI_ROOT }}/setvars.sh
74+
source "${{ env.ONEAPI_ROOT }}/setvars.sh"
7575
pip install pytest
7676
pytest -s -v --pyargs mkl_random

.github/workflows/conda-package-cf.yml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ jobs:
5353
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
5454
5555
- name: Add conda to system path
56-
run: echo $CONDA/bin >> $GITHUB_PATH
56+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
5757

5858
- name: Install conda-build
5959
run: conda install conda-build
6060

6161
- name: Build conda package
6262
run: |
63-
CHANNELS="-c conda-forge --override-channels"
64-
VERSIONS="--python ${{ matrix.python }} --numpy ${{ matrix.numpy }}"
65-
TEST="--no-test"
63+
CHANNELS=(-c conda-forge --override-channels)
64+
VERSIONS=(--python "${{ matrix.python }}" --numpy "${{ matrix.numpy }}")
65+
TEST=(--no-test)
6666
6767
conda build \
68-
$TEST \
69-
$VERSIONS \
70-
$CHANNELS \
68+
"${TEST[@]}" \
69+
"${VERSIONS[@]}" \
70+
"${CHANNELS[@]}" \
7171
conda-recipe-cf
7272
7373
- name: Upload artifact
@@ -125,7 +125,6 @@ jobs:
125125

126126
- name: Setup MSVC
127127
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
128-
129128
- name: Build conda package
130129
run: conda build --no-test --python ${{ matrix.python }} --numpy ${{ matrix.numpy }} -c conda-forge --override-channels conda-recipe-cf
131130

@@ -163,27 +162,27 @@ jobs:
163162
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
164163

165164
- name: Add conda to system path
166-
run: echo $CONDA/bin >> $GITHUB_PATH
165+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
167166

168167
- name: Install conda-build
169168
run: conda install conda-build
170169

171170
- name: Create conda channel
172171
run: |
173-
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
174-
conda index $GITHUB_WORKSPACE/channel || exit 1
175-
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64 || exit 1
176-
conda index $GITHUB_WORKSPACE/channel || exit 1
172+
mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
173+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
174+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
175+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
177176
# Test channel
178-
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
177+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
179178
cat ver.json
180179
181180
- name: Collect dependencies
182181
run: |
183-
. $CONDA/etc/profile.d/conda.sh
184-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
185-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
186-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
182+
. "$CONDA/etc/profile.d/conda.sh"
183+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
184+
export PACKAGE_VERSION
185+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c conda-forge --override-channels --only-deps --dry-run > lockfile
187186
cat lockfile
188187
189188
- name: Set pkgs_dirs
@@ -204,17 +203,17 @@ jobs:
204203
205204
- name: Install mkl_random
206205
run: |
207-
. $CONDA/etc/profile.d/conda.sh
208-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
209-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
210-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS
206+
. "$CONDA/etc/profile.d/conda.sh"
207+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
208+
export PACKAGE_VERSION
209+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" pytest "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c conda-forge --override-channels
211210
# Test installed packages
212211
conda list
213212
214213
- name: Run tests
215214
run: |
216-
. $CONDA/etc/profile.d/conda.sh
217-
conda activate ${{ env.TEST_ENV_NAME }}
215+
. "$CONDA/etc/profile.d/conda.sh"
216+
conda activate "${{ env.TEST_ENV_NAME }}"
218217
pytest -vv --pyargs ${{ env.MODULE_NAME }}
219218
220219
test_windows:

.github/workflows/conda-package.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,26 @@ jobs:
4949
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
5050
5151
- name: Add conda to system path
52-
run: echo $CONDA/bin >> $GITHUB_PATH
52+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
5353

5454
- name: Install conda-build
5555
run: conda install conda-build
5656

5757
- name: Store conda paths as envs
5858
shell: bash -el {0}
5959
run: |
60-
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> $GITHUB_ENV
60+
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> "$GITHUB_ENV"
6161
6262
- name: Build conda package
6363
run: |
64-
CHANNELS="-c https://software.repos.intel.com/python/conda -c conda-forge --override-channels"
65-
VERSIONS="--python ${{ matrix.python }}"
66-
TEST="--no-test"
64+
CHANNELS=(-c https://software.repos.intel.com/python/conda -c conda-forge --override-channels)
65+
VERSIONS=(--python "${{ matrix.python }}")
66+
TEST=(--no-test)
6767
6868
conda build \
69-
$TEST \
70-
$VERSIONS \
71-
$CHANNELS \
69+
"${TEST[@]}" \
70+
"${VERSIONS[@]}" \
71+
"${CHANNELS[@]}" \
7272
conda-recipe
7373
7474
- name: Upload artifact
@@ -120,10 +120,10 @@ jobs:
120120
- name: Store conda paths as envs
121121
shell: bash -el {0}
122122
run: |
123-
echo "CONDA_BLD=$CONDA_PREFIX\\conda-bld\\win-64\\" >> $GITHUB_ENV
123+
echo "CONDA_BLD=${CONDA_PREFIX}\\conda-bld\\win-64\\" >> "$GITHUB_ENV"
124124
125125
- name: Build conda package
126-
run: conda build --no-test --python ${{ matrix.python }} -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels conda-recipe
126+
run: conda build --no-test --python "${{ matrix.python }}" -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels conda-recipe
127127

128128
- name: Upload artifact
129129
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
@@ -160,27 +160,27 @@ jobs:
160160
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
161161

162162
- name: Add conda to system path
163-
run: echo $CONDA/bin >> $GITHUB_PATH
163+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
164164

165165
- name: Install conda-build
166166
run: conda install conda-build
167167

168168
- name: Create conda channel
169169
run: |
170-
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
171-
conda index $GITHUB_WORKSPACE/channel || exit 1
172-
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64 || exit 1
173-
conda index $GITHUB_WORKSPACE/channel || exit 1
170+
mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
171+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
172+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
173+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
174174
# Test channel
175-
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
175+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
176176
cat ver.json
177177
178178
- name: Collect dependencies
179179
run: |
180-
. $CONDA/etc/profile.d/conda.sh
181-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
182-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
183-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
180+
. "$CONDA/etc/profile.d/conda.sh"
181+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
182+
export PACKAGE_VERSION
183+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels --only-deps --dry-run > lockfile
184184
cat lockfile
185185
186186
- name: Set pkgs_dirs
@@ -201,19 +201,19 @@ jobs:
201201
202202
- name: Install mkl_random
203203
run: |
204-
. $CONDA/etc/profile.d/conda.sh
205-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
206-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
207-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS
208-
conda activate ${{ env.TEST_ENV_NAME }}
204+
. "$CONDA/etc/profile.d/conda.sh"
205+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
206+
export PACKAGE_VERSION
207+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" pytest "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels
208+
conda activate "${{ env.TEST_ENV_NAME }}"
209209
210210
# Test installed packages
211211
conda list
212212
213213
- name: Run tests
214214
run: |
215-
. $CONDA/etc/profile.d/conda.sh
216-
conda activate ${{ env.TEST_ENV_NAME }}
215+
. "$CONDA/etc/profile.d/conda.sh"
216+
conda activate "${{ env.TEST_ENV_NAME }}"
217217
pytest -vv --pyargs ${{ env.MODULE_NAME }}
218218
219219
test_windows:
@@ -259,7 +259,7 @@ jobs:
259259
run: |
260260
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64
261261
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}\channel\win-64
262-
python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel
262+
python -m conda_index "${{ env.GITHUB_WORKSPACE }}/channel"
263263
264264
# Test channel
265265
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json
@@ -309,5 +309,5 @@ jobs:
309309
310310
- name: Run tests
311311
run: |
312-
conda activate -n ${{ env.TEST_ENV_NAME }}
312+
conda activate -n "${{ env.TEST_ENV_NAME }}"
313313
pytest -v --pyargs ${{ env.MODULE_NAME }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Autoupdate pre-commit
2+
3+
on:
4+
workflow_dispatch:
5+
# To guarantee Maintained check is occasionally updated. See
6+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
7+
schedule:
8+
- cron: '28 2 * * 6' # Saturday at 02:28 UTC
9+
10+
permissions: read-all
11+
12+
jobs:
13+
autoupdate:
14+
name: Autoupdate
15+
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 10
18+
19+
permissions:
20+
# Needed to create a PR with autoupdate changes
21+
contents: write
22+
pull-requests: write
23+
24+
steps:
25+
- name: Checkout repo
26+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
28+
- name: Set up python
29+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v5.6.0
30+
with:
31+
python-version: '3.14'
32+
33+
- name: Install pre-commit
34+
run: pip install pre-commit
35+
36+
- name: Run pre-commit autoupdate
37+
run: pre-commit autoupdate
38+
39+
- name: Create a PR with autoupdate changes
40+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
41+
with:
42+
commit-message: 'chore: update pre-commit hooks'
43+
add-paths: .pre-commit-config.yaml
44+
branch: 'bot/pre-commit-autoupdate'
45+
delete-branch: true
46+
title: Weekly pre-commit autoupdate
47+
body: |
48+
This PR updates the `.pre-commit-config.yaml` using `pre-commit autoupdate`.
49+
labels: autoupdate

0 commit comments

Comments
 (0)