Skip to content

Commit 2bee3b9

Browse files
authored
Pin lint tools versions (#1429)
* chore: include missing YAML extension * chore: pin exact lint tools versions * chore: offer pre-commit hooks at same versions * style: adjust to latest black version * docs: describe use of pre-commit hooks
1 parent e5fc6ed commit 2bee3b9

File tree

7 files changed

+36
-7
lines changed

7 files changed

+36
-7
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ insert_final_newline = true
1010
trim_trailing_whitespace = true
1111
max_line_length = 88
1212

13-
[*.{json,yml}]
13+
[*.{json,yml,yaml}]
1414
indent_size = 2
1515

1616
[*.{md,rst}]

.github/CONTRIBUTING.rst

+9
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ Ready to contribute? Here's how to set up cobrapy for local development.
105105
106106
tox --parallel
107107
108+
We also provide some `git pre-commit hooks <https://pre-commit.com/>`_ for
109+
your convenience. They run our linting steps and will ensure that your
110+
contributions pass linting with every commit that you make. When you want to
111+
use them, run the following commands.
112+
113+
.. code-block:: console
114+
115+
pip install pre-commit
116+
pre-commit install
108117
109118
7. Push your branch to GitHub.
110119

.pre-commit-config.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pycqa/isort
3+
rev: 6.0.1
4+
hooks:
5+
- id: isort
6+
name: isort (python)
7+
args: [--check-only, --diff, src/cobra, setup.py, tests]
8+
- repo: https://github.com/psf/black
9+
rev: 25.1.0
10+
hooks:
11+
- id: black
12+
args: [--check, --diff, src/cobra, setup.py, tests]
13+
- repo: https://github.com/pycqa/flake8
14+
rev: 7.1.2
15+
hooks:
16+
- id: flake8
17+
args: [src/cobra, setup.py, tests]
18+
additional_dependencies:
19+
- flake8-docstrings
20+
- flake8-bugbear

src/cobra/core/gene.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def from_symbolic(cls, sympy_gpr: Union[spl.BooleanFunction, Symbol]) -> "GPR":
680680
"""
681681

682682
def _sympy_to_ast(
683-
sympy_expr: Union[spl.BooleanFunction, Symbol]
683+
sympy_expr: Union[spl.BooleanFunction, Symbol],
684684
) -> Union[BoolOp, Name]:
685685
if sympy_expr.func is spl.Or:
686686
return BoolOp(

src/cobra/io/dict.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969

7070
def _fix_type(
71-
value: Union[str, float, bool, Set, Dict]
71+
value: Union[str, float, bool, Set, Dict],
7272
) -> Union[str, float, bool, List, OrderedDict]:
7373
"""Convert possible types to correct Python types.
7474

tests/test_core/test_solution.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def test_solution_contains_only_reaction_specific_values(
13-
solved_model: Tuple[Solution, "Model"]
13+
solved_model: Tuple[Solution, "Model"],
1414
) -> None:
1515
"""Test solution contains specific reaction values."""
1616
solution, model = solved_model

tox.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ commands =
3939
[testenv:isort]
4040
skip_install = True
4141
deps=
42-
isort
42+
isort ==6.0.1
4343
commands=
4444
isort --check-only --diff {toxinidir}/src/cobra {toxinidir}/setup.py {toxinidir}/tests
4545

4646
[testenv:black]
4747
skip_install = True
4848
deps=
49-
black
49+
black ==25.1.0
5050
commands=
5151
black --check --diff {toxinidir}/src/cobra {toxinidir}/setup.py {toxinidir}/tests
5252

5353
[testenv:flake8]
5454
skip_install = True
5555
deps=
56-
flake8
56+
flake8 ==7.1.2
5757
flake8-docstrings
5858
flake8-bugbear
5959
commands=

0 commit comments

Comments
 (0)