Skip to content

Use isort and add pre-commit workflow #143

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

Closed
wants to merge 7 commits into from
Closed
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
51 changes: 51 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[flake8]
extend-ignore =
# whitespace before ':' (currently conflicts with black formatting):
E203,
# line too long (in docstrings):
E501,
# ‘from module import *’ used; unable to detect undefined names:
F403,
# doc line too long (105 > 80 characters):
W505,
# missing docstring in public module:
D100,
# missing docstring in public class:
D101,
# missing docstring in public method:
D102,
# missing docstring in public function:
D103,
# missing docstring in public package:
D104,
# missing docstring in magic method:
D105,
# missing docstring in __init__:
D107,
# no blank lines allowed after function docstring:
D202,
# 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,
# first word of the first line should be properly capitalized
D403,

per-file-ignores =
mkl_fft/__init__.py: E402, F401
mkl_fft/interfaces/__init__.py: F401
mkl_fft/interfaces/scipy_fft.py: F401
mkl_fft/interfaces/numpy_fft.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
10 changes: 10 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# $ git config blame.ignoreRevsFile .git-blame-ignore-revs

# Add pre-commit hooks
e9362b264878bf849b1d6ab0994153cb3d497bad

# Add isort
cd508d5703a3d6088f5a6414057e70e9f20895c5

# Run black
c05764aaa61ca55109ebb5e214cc51737b11bb2d
5 changes: 2 additions & 3 deletions .github/workflows/conda-package-cf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ env:
MODULE_NAME: mkl_fft
TEST_ENV_NAME: test_mkl_fft
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); d = j['mkl_fft'][0];"
VER_SCRIPT2: "print('='.join((d[s] for s in ('version', 'build'))))"
VER_SCRIPT2: "print('='.join((d[s] for s in ('version', 'build'))))"

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -280,4 +280,3 @@ jobs:
shell: cmd /C CALL {0}
run: >-
conda activate ${{ env.TEST_ENV_NAME }} && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}

3 changes: 1 addition & 2 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
MODULE_NAME: mkl_fft
TEST_ENV_NAME: test_mkl_fft
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); d = j['mkl_fft'][0];"
VER_SCRIPT2: "print('='.join((d[s] for s in ('version', 'build'))))"
VER_SCRIPT2: "print('='.join((d[s] for s in ('version', 'build'))))"

jobs:
build:
Expand Down Expand Up @@ -278,4 +278,3 @@ jobs:
shell: cmd /C CALL {0}
run: >-
conda activate ${{ env.TEST_ENV_NAME }} && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}

22 changes: 22 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: pre-commit

on:
pull_request:
push:
branches: [master]

permissions: read-all

jobs:
pre-commit:
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Version of clang-format
run: |
clang-format --version
- uses: pre-commit/action@v3.0.1
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.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/psf/black
rev: 25.1.0
hooks:
- id: black
exclude: "_vendored/conv_template.py"

- repo: https://github.com/pycqa/flake8
rev: 7.1.2
hooks:
- id: flake8
args: ["--config=.flake8"]
additional_dependencies:
- flake8-docstrings==1.7.0
- flake8-bugbear==24.4.26

- repo: https://github.com/pycqa/isort
rev: 5.13.2
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.14.0
hooks:
- id: pretty-format-toml
args: [--autofix]

- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
args: ["-i"]
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Fix for issue #29.
1.0.7
=====
Improved exception message raised if MKL is signalling an error. The message now includes MKL's own description of the exception.
This partially improves #24.
This partially improves #24.

Improved argument validation for ND transforms aligning with scipy 1.2.0

Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Security Policy
Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation.
Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation.

## Reporting a Vulnerability
Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html).
Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html).
2 changes: 1 addition & 1 deletion _vendored/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

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