Skip to content

Commit

Permalink
ruff config + make compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Jan 4, 2024
1 parent 4df1e8f commit 8134cd8
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 19 deletions.
24 changes: 15 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ repos:
args: [--allow-multiple-documents]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.11
hooks:
- id: black-jupyter
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.11
args: ["--line-length", "79"]
# Run the linter.
- id: ruff
args:
- --fix
- --config
- python/sdist/pyproject.toml

# Run the formatter.
- id: ruff-format
args:
- --config
- python/sdist/pyproject.toml

exclude: '^(ThirdParty|models)/'
2 changes: 1 addition & 1 deletion documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config

import os
import re
import subprocess
Expand All @@ -18,6 +17,7 @@
import exhale_multiproject_monkeypatch
import mock
import pandas as pd
import sphinx
import sympy as sp
from exhale import configs as exhale_configs
from sphinx.transforms.post_transforms import ReferencesResolver
Expand Down
11 changes: 7 additions & 4 deletions python/sdist/amici/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,21 @@ def _imported_from_setup() -> bool:
# from .swig_wrappers
hdf5_enabled = "readSolverSettingsFromHDF5" in dir()
# These modules require the swig interface and other dependencies
from .numpy import ExpDataView, ReturnDataView
from .numpy import ExpDataView, ReturnDataView # noqa: F401
from .pandas import *
from .swig_wrappers import *

# These modules don't require the swig interface
from typing import Protocol, runtime_checkable

from .de_export import DEExporter, DEModel
from .sbml_import import SbmlImporter, assignmentRules2observables
from .de_export import DEExporter, DEModel # noqa: F401
from .sbml_import import ( # noqa: F401
SbmlImporter,
assignmentRules2observables,
)

@runtime_checkable
class ModelModule(Protocol):
class ModelModule(Protocol): # noqa: F811
"""Type of AMICI-generated model modules.
To enable static type checking."""
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/__init__.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version currently installed."
)

from .TPL_MODELNAME import *
from .TPL_MODELNAME import getModel as get_model
from .TPL_MODELNAME import * # noqa: F403, F401
from .TPL_MODELNAME import getModel as get_model # noqa: F401

__version__ = "TPL_PACKAGE_VERSION"
2 changes: 1 addition & 1 deletion python/sdist/amici/gradient_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _check_results(
"""

result = rdata[field]
if type(result) is float:
if type(result) is float: # noqa E721
result = np.array(result)

_check_close(
Expand Down
5 changes: 4 additions & 1 deletion python/sdist/amici/petab/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Various helper functions for working with PEtab problems."""
import re
from typing import Dict, Tuple, Union
from typing import TYPE_CHECKING, Dict, Tuple, Union

import libsbml
import pandas as pd
Expand All @@ -9,6 +9,9 @@
from petab.mapping import resolve_mapping
from petab.models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML

if TYPE_CHECKING:
pysb = None


def get_states_in_condition_table(
petab_problem: petab.Problem,
Expand Down
5 changes: 5 additions & 0 deletions python/sdist/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79

[tool.ruff]
line-length = 79
ignore = ["E402", "F403", "F405", "E741"]
extend-include = ["*.ipynb"]
1 change: 1 addition & 0 deletions python/tests/test_pysb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PYSB model tests"""
# flake8: noqa: F821

import importlib
import logging
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import re
import sys
from pathlib import Path
from typing import List, Set, Tuple
from typing import TYPE_CHECKING, List, Set, Tuple

import pytest

if TYPE_CHECKING:
from _pytest.reports import TestReport

# stores passed SBML semantic test suite IDs
passed_ids = []

Expand Down

0 comments on commit 8134cd8

Please sign in to comment.