Skip to content

Commit

Permalink
Clean up quality checks (#40)
Browse files Browse the repository at this point in the history
* ruff instead of a range of different tools
* update python requirement and python versions on GHA
* update pre-commit config


Closes #5
  • Loading branch information
dweindl authored Oct 9, 2024
1 parent 6aea82e commit a8b40bf
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 89 deletions.
16 changes: 0 additions & 16 deletions .flake8

This file was deleted.

15 changes: 5 additions & 10 deletions .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
python-version: ['3.12']

steps:
- name: Check out repository
Expand All @@ -74,23 +74,18 @@ jobs:
- name: Install dependencies
run: pip install tox pre-commit

# failing on github, no size environment in tox.ini
# - name: Check repository size
# run: tox -e size

- name: Run quality checks
timeout-minutes: 5
run: tox -e pyroma,flake8
run: tox -e pyroma

# failing on github
# - name: Run pre-commit hooks
# run: pre-commit run --all-files
- name: Run pre-commit hooks
run: pre-commit run --all-files

docs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
python-version: ['3.12']

steps:
- name: Check out repository
Expand Down
2 changes: 0 additions & 2 deletions .isort.cfg

This file was deleted.

47 changes: 16 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,8 @@
# `pre-commit run --all-files` as by default only changed files are checked

repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
description: The uncompromising code formatter
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.6.3
hooks:
- id: nbqa-black
- id: nbqa-pyupgrade
args: [--py36-plus]
- id: nbqa-isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-yaml
description: Check yaml files for parseable syntax
Expand All @@ -54,11 +31,19 @@ repos:
description: Replace or check mixed line endings
- id: trailing-whitespace
description: Trim trailing whitespaces
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.9
hooks:
- id: style
name: Check style
description: Check style
entry: tox -e project,flake8 --
language: python
types: [python]
# Run the linter.
- id: ruff
args:
- --fix
- --config
- pyproject.toml

# Run the formatter.
- id: ruff-format
args:
- --config
- pyproject.toml
11 changes: 7 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import sys

import mock
from unittest import mock

# Configuration file for the Sphinx documentation builder.
#
Expand Down Expand Up @@ -61,8 +60,12 @@


autodoc_mock_imports = [
"amici", "amici.amici", "amici.petab", "amici.petab.simulations",
"amici.petab.parameter_mapping", "amici.petab.conditions"
"amici",
"amici.amici",
"amici.petab",
"amici.petab.simulations",
"amici.petab.parameter_mapping",
"amici.petab.conditions",
]
for mod_name in autodoc_mock_imports:
sys.modules[mod_name] = mock.MagicMock()
Expand Down
1 change: 0 additions & 1 deletion examples/derivative.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"from scipy.optimize import rosen, rosen_der\n",
"\n",
"from fiddy import MethodId, get_derivative\n",
Expand Down
1 change: 1 addition & 0 deletions fiddy/derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Derivative:
success:
Whether the derivative was successfully computed.
"""

hide_columns = [
"pending_computers",
"computers",
Expand Down
2 changes: 1 addition & 1 deletion fiddy/extensions/amici/amici.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import amici.petab.simulations
import numpy as np
import petab.v1 as petab
from amici.petab.conditions import create_edatas
from amici.petab.parameter_mapping import create_parameter_mapping
from amici.petab.simulations import LLH, SLLH
from amici.petab.conditions import create_edatas
from petab.v1.C import LIN, LOG, LOG10

from ...constants import Type
Expand Down
25 changes: 24 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,28 @@ requires = [
]
build-backend = "setuptools.build_meta"

[tool.black]
[tool.ruff]
line-length = 79
lint.select = [
"F", # Pyflakes
"I", # isort
# "D", # pydocstyle (PEP 257) FIXME enable later
"S", # flake8-bandit
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"T20", # flake8-print
"W", # pycodestyle Warnings
"E", # pycodestyle Errors
"UP", # pyupgrade
# "ANN", # flakes-annotations
]
lint.ignore = [
"S101", # Use of assert detected
# FIXME
"E501", # Line too long
"T201", # print statement
"F403", # star import
"F401", # unused import
]
[tool.ruff.lint.pydocstyle]
convention = "pep257"
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ classifiers =
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.9
keywords =
finite difference
gradient check
Expand All @@ -40,7 +40,7 @@ install_requires =
numpy
pandas

python_requires = >=3.9
python_requires = >=3.10
include_package_data = True

# Where is my code
Expand Down
6 changes: 3 additions & 3 deletions tests/test_derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def test_get_derivative_relative():
) # cardinal direction, simplifies to this, but usually need dot product

g_a = (f_a - f_0) / size
g_r = (f_r - f_0) / (
point * direction * size
).sum() # cardinal direction, simplifies to this, but usually need dot product
g_r = (
(f_r - f_0) / (point * direction * size).sum()
) # cardinal direction, simplifies to this, but usually need dot product

# Fiddy finite difference derivatives
kwargs = {
Expand Down
18 changes: 0 additions & 18 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
envlist =
clean
pyroma
flake8
doc

# Base-environment
Expand Down Expand Up @@ -40,23 +39,6 @@ commands =
description =
Check the package friendliness

[testenv:flake8]
skip_install = true
deps =
flake8 >= 6.0.0
flake8-bandit >= 4.1.1
flake8-bugbear >= 23.3.23
flake8-colors >= 0.1.9
flake8-comprehensions >= 3.12.0
flake8-print >= 5.0.0
flake8-black >= 0.3.6
flake8-isort >= 6.0.0
flake8-docstrings >= 1.7.0
commands =
flake8 fiddy tests
description =
Run flake8 with various plugins.

[testenv:doc]
extras =
doc
Expand Down

0 comments on commit a8b40bf

Please sign in to comment.