-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformat/restyle files according to rules in .pre-commit-config.yaml
Reformatted the files in the repository according to rules in a new file ".pre-commit-config.yaml". Have to install pre-commit either through pip or conda and then "pre-commit install" to install the git hooks. The pre-commit lints or reformats many file types by using separate linters and autoformaters that are installed as part of pre-commit. Uses "ruff" for Python files, but presently configured only for autoformatting. Turned off "ruff" linting because it found over 300 problems, some of which there weren't easy answers for.
- Loading branch information
Showing
129 changed files
with
42,832 additions
and
95,084 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,87 +1,94 @@ | ||
--- | ||
name: Python application | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master", "develop", "develop-specact" ] | ||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master, develop, develop-specact] | ||
|
||
permissions: | ||
contents: read | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
cache: "pip" | ||
- name: Install dependencies | ||
run: | | ||
pip install flake8 | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --ignore=F821 --show-source --statistics --exclude=build/* | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
test-pytest: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
pandas-version: [""] | ||
include: | ||
- python-version: "3.11" | ||
pandas-version: "pandas>2.0" | ||
coverage: true | ||
- python-version: "3.11" | ||
pandas-version: "pandas>1.5,<2.0" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
- name: Install hsp2 | ||
run: | | ||
# install the hsp2 executable | ||
pip install .[dev] | ||
- if: ${{ matrix.pandas-version }} | ||
run: pip install "${{ matrix.pandas-version }}" | ||
- if: ${{ matrix.coverage }} | ||
run: | | ||
# python coverage | ||
NUMBA_DISABLE_JIT=1 pytest --cov --cov-branch --cov-report term-missing | ||
- if: ${{ ! matrix.coverage }} | ||
run: pytest | ||
|
||
test-cmd: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
- name: Install hsp2 | ||
run: | | ||
# install the hsp2 executable | ||
pip install . | ||
- name: Run hsp2 | ||
run: | | ||
# TODO: find much shorter test case. | ||
hsp2 import_uci ./tests/test10/HSP2results/test10.uci _temp_test10.h5 | ||
hsp2 run _temp_test10.h5 | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
cache: pip | ||
- name: Install dependencies | ||
run: | | ||
pip install flake8 | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or | ||
# undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --ignore=F821 \ | ||
--show-source --statistics --exclude=build/* | ||
# exit-zero treats all errors as warnings. | ||
# The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 \ | ||
--max-line-length=127 --statistics | ||
test-pytest: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
python-version: ['3.9', '3.10', '3.11', '3.12'] | ||
pandas-version: [''] | ||
include: | ||
- python-version: '3.11' | ||
pandas-version: pandas>2.0 | ||
coverage: true | ||
- python-version: '3.11' | ||
pandas-version: pandas>1.5,<2.0 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
- name: Install hsp2 | ||
run: | | ||
# install the hsp2 executable | ||
pip install .[dev] | ||
- if: ${{ matrix.pandas-version }} | ||
run: pip install "${{ matrix.pandas-version }}" | ||
- if: ${{ matrix.coverage }} | ||
run: | | ||
# python coverage | ||
NUMBA_DISABLE_JIT=1 pytest --cov --cov-branch --cov-report \ | ||
term-missing | ||
- if: ${{ ! matrix.coverage }} | ||
run: pytest | ||
|
||
test-cmd: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
python-version: ['3.9', '3.10', '3.11', '3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
- name: Install hsp2 | ||
run: | | ||
# install the hsp2 executable | ||
pip install . | ||
- name: Run hsp2 | ||
run: | | ||
# TODO: find much shorter test case. | ||
hsp2 import_uci \ | ||
./tests/test10/HSP2results/test10.uci \ | ||
_temp_test10.h5 | ||
hsp2 run _temp_test10.h5 |
This file contains 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,96 @@ | ||
--- | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
|
||
exclude: | | ||
(?x)^( | ||
.*\.hbn| | ||
.*\.wdm| | ||
.*\.hdf5| | ||
.*\.h5 | ||
)$ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: check-executables-have-shebangs | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-shebang-scripts-are-executable | ||
- id: check-toml | ||
- id: check-xml | ||
- id: end-of-file-fixer | ||
exclude: notebooks/tstoolbox_plot_bash.sh | ||
- id: fix-encoding-pragma | ||
args: [--remove] | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
exclude: notebooks/tstoolbox_plot_bash.sh | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.5.5 | ||
hooks: | ||
# Run the linter. | ||
# Uncomment the following lines to enable the linter. | ||
# Right now way to many things fail. | ||
# - id: ruff | ||
# types_or: [python, pyi, jupyter] | ||
# args: [--fix] | ||
|
||
# Run the linter sort imports. | ||
- id: ruff | ||
types_or: [python, pyi, jupyter] | ||
args: [--select, I, --fix] | ||
|
||
# Run the formatter. | ||
- id: ruff-format | ||
types_or: [python, pyi, jupyter] | ||
|
||
- repo: https://github.com/pappasam/toml-sort | ||
rev: v0.23.1 | ||
hooks: | ||
- id: toml-sort-fix | ||
args: [--in-place, --spaces-indent-inline-array, '4'] | ||
|
||
- repo: https://github.com/adrienverge/yamllint.git | ||
rev: v1.35.1 | ||
hooks: | ||
- id: yamllint | ||
args: [--format, parsable, --strict] | ||
|
||
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt | ||
rev: 0.2.3 | ||
hooks: | ||
- id: yamlfmt | ||
|
||
- repo: https://github.com/jumanjihouse/pre-commit-hooks | ||
rev: 3.0.0 | ||
hooks: | ||
- id: shellcheck | ||
args: [-s, bash] | ||
|
||
- repo: https://github.com/lovesegfault/beautysh | ||
rev: v6.2.1 | ||
hooks: | ||
- id: beautysh | ||
args: [--indent-size, '4'] | ||
|
||
- repo: https://github.com/asottile/blacken-docs | ||
rev: 1.18.0 | ||
hooks: | ||
- id: blacken-docs | ||
|
||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.16.0 | ||
hooks: | ||
- id: pyupgrade | ||
|
||
- repo: https://github.com/commitizen-tools/commitizen | ||
rev: v3.28.0 | ||
hooks: | ||
- id: commitizen | ||
stages: [commit-msg] |
This file contains 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.