diff --git a/pyproject.toml b/pyproject.toml index 048b438df..a64cb9736 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,24 +1,24 @@ [build-system] requires = [ - 'setuptools>=40.6.0', - 'wheel' + "setuptools>=40.6.0", + "wheel" ] build-backend = "setuptools.build_meta" [tool.black] line-length = 88 -python-version = ['py36'] -include = '\.pyi?$' -exclude = ''' +target-version = ["py38"] +include = "\\.pyi?$" +exclude = """ ( /( - \.eggs # exclude a few common directories in the - | \.git # root of the project - | \.hg - | \.mypy_cache - | \.tox - | \.venv + \\.eggs # exclude a few common directories in the + | \\.git # root of the project + | \\.hg + | \\.mypy_cache + | \\.tox + | \\.venv | _build | buck-out | build @@ -27,4 +27,4 @@ exclude = ''' | benchmarks )/ ) -''' +""" diff --git a/src/cobra/core/configuration.py b/src/cobra/core/configuration.py index 43512261c..576fcf6ec 100644 --- a/src/cobra/core/configuration.py +++ b/src/cobra/core/configuration.py @@ -1,6 +1,5 @@ """Provide a global configuration object.""" - import logging import pathlib import types diff --git a/src/cobra/core/species.py b/src/cobra/core/species.py index 39749fcd0..486ea23a9 100644 --- a/src/cobra/core/species.py +++ b/src/cobra/core/species.py @@ -1,6 +1,5 @@ """Define the Species class, used as a base for Gene and Metabolite.""" - from copy import deepcopy from typing import TYPE_CHECKING, FrozenSet, Optional diff --git a/src/cobra/exceptions.py b/src/cobra/exceptions.py index 6736b1e72..95cf1155a 100644 --- a/src/cobra/exceptions.py +++ b/src/cobra/exceptions.py @@ -1,4 +1,5 @@ """Module for shared exceptions in the Cobra package.""" + import optlang.interface diff --git a/src/cobra/flux_analysis/gapfilling.py b/src/cobra/flux_analysis/gapfilling.py index 0347f3925..0f572bf75 100644 --- a/src/cobra/flux_analysis/gapfilling.py +++ b/src/cobra/flux_analysis/gapfilling.py @@ -1,6 +1,5 @@ """Provide the base class and utility function for gap filling.""" - import logging from typing import TYPE_CHECKING, Dict, List, Optional, Union diff --git a/src/cobra/flux_analysis/loopless.py b/src/cobra/flux_analysis/loopless.py index e218f53ac..ca09b862c 100644 --- a/src/cobra/flux_analysis/loopless.py +++ b/src/cobra/flux_analysis/loopless.py @@ -1,6 +1,5 @@ """Provide functions to remove thermodynamically infeasible loops.""" - from typing import TYPE_CHECKING, Dict, Optional, Union import numpy as np diff --git a/src/cobra/flux_analysis/variability.py b/src/cobra/flux_analysis/variability.py index 4b1066f2b..38cd937f4 100644 --- a/src/cobra/flux_analysis/variability.py +++ b/src/cobra/flux_analysis/variability.py @@ -1,6 +1,5 @@ """Provide variability based methods such as flux variability or gene essentiality.""" - import logging from typing import TYPE_CHECKING, List, Optional, Set, Tuple, Union from warnings import warn diff --git a/src/cobra/io/__init__.py b/src/cobra/io/__init__.py index 66d8a1b92..f81680c1c 100644 --- a/src/cobra/io/__init__.py +++ b/src/cobra/io/__init__.py @@ -1,6 +1,5 @@ """Provide functions for loading and saving metabolic models.""" - from cobra.io.dict import model_from_dict, model_to_dict from cobra.io.json import from_json, load_json_model, save_json_model, to_json from cobra.io.mat import load_matlab_model, save_matlab_model diff --git a/src/cobra/io/json.py b/src/cobra/io/json.py index f6bded5bc..6ffbebcf7 100644 --- a/src/cobra/io/json.py +++ b/src/cobra/io/json.py @@ -1,4 +1,5 @@ """Provide functions for I/O in JSON format.""" + from pathlib import Path from typing import IO, TYPE_CHECKING, Any, Union @@ -72,7 +73,7 @@ def save_json_model( filename: Union[str, Path, IO], sort: bool = False, pretty: bool = False, - **kwargs: Any + **kwargs: Any, ) -> None: """Write the cobra model to a file in JSON format. diff --git a/src/cobra/io/mat.py b/src/cobra/io/mat.py index e37f7cf5d..c3a7be0bd 100644 --- a/src/cobra/io/mat.py +++ b/src/cobra/io/mat.py @@ -213,19 +213,23 @@ def _cell_to_str_list( """ if str_prefix and pattern_split: return [ - [ - str_prefix + str_found if str_prefix not in str_found else str_found - for str_found in pattern_split.findall(str(each_cell[0][0])) - ] - if np.size(each_cell[0]) - else empty_value + ( + [ + str_prefix + str_found if str_prefix not in str_found else str_found + for str_found in pattern_split.findall(str(each_cell[0][0])) + ] + if np.size(each_cell[0]) + else empty_value + ) for each_cell in m_cell ] elif pattern_split: return [ - pattern_split.findall(str(each_cell[0][0])) - if np.size(each_cell[0]) - else empty_value + ( + pattern_split.findall(str(each_cell[0][0])) + if np.size(each_cell[0]) + else empty_value + ) for each_cell in m_cell ] else: @@ -481,9 +485,11 @@ def mat_parse_notes( # things like PMC or OMIM, but those are placed as string in notes. _notes = _cell_to_str_list(mat_struct[caseunfold[mat_key]][0, 0]) notes[name] = [ - _pubmed_re.sub("", x).strip() - if x and len(_pubmed_re.sub("", x).strip()) - else None + ( + _pubmed_re.sub("", x).strip() + if x and len(_pubmed_re.sub("", x).strip()) + else None + ) for x in _notes ] elif mat_key == "rxnConfidenceScores".casefold(): diff --git a/src/cobra/io/sbml.py b/src/cobra/io/sbml.py index 4d07f9326..5445ce951 100644 --- a/src/cobra/io/sbml.py +++ b/src/cobra/io/sbml.py @@ -614,9 +614,9 @@ def _sbml_to_model( { "familyName": c.getFamilyName() if c.isSetFamilyName() else None, "givenName": c.getGivenName() if c.isSetGivenName() else None, - "organisation": c.getOrganisation() - if c.isSetOrganisation() - else None, + "organisation": ( + c.getOrganisation() if c.isSetOrganisation() else None + ), "email": c.getEmail() if c.isSetEmail() else None, } ) diff --git a/src/cobra/io/web/__init__.py b/src/cobra/io/web/__init__.py index 2d4625a2e..d55a41985 100644 --- a/src/cobra/io/web/__init__.py +++ b/src/cobra/io/web/__init__.py @@ -1,6 +1,5 @@ """Provide functionality to access remote model repositories.""" - from .abstract_model_repository import AbstractModelRepository from .bigg_models_repository import BiGGModels from .biomodels_repository import BioModels diff --git a/src/cobra/io/web/abstract_model_repository.py b/src/cobra/io/web/abstract_model_repository.py index fa547cf1a..9db3cefc4 100644 --- a/src/cobra/io/web/abstract_model_repository.py +++ b/src/cobra/io/web/abstract_model_repository.py @@ -1,6 +1,5 @@ """Provide an abstract base class that describes a remote model repository.""" - from abc import ABC, abstractmethod from typing import Union diff --git a/src/cobra/io/web/bigg_models_repository.py b/src/cobra/io/web/bigg_models_repository.py index e961734a1..23e6fd660 100644 --- a/src/cobra/io/web/bigg_models_repository.py +++ b/src/cobra/io/web/bigg_models_repository.py @@ -1,6 +1,5 @@ """Provide a concrete implementation of the BioModels repository interface.""" - from io import BytesIO import httpx diff --git a/src/cobra/io/web/biomodels_repository.py b/src/cobra/io/web/biomodels_repository.py index fa53cf4c1..77bbffe06 100644 --- a/src/cobra/io/web/biomodels_repository.py +++ b/src/cobra/io/web/biomodels_repository.py @@ -1,6 +1,5 @@ """Provide functions for loading metabolic models over the wire.""" - import gzip from io import BytesIO from typing import List diff --git a/src/cobra/io/web/cobrapy_repository.py b/src/cobra/io/web/cobrapy_repository.py index 9a1d225f1..969bbd5cf 100644 --- a/src/cobra/io/web/cobrapy_repository.py +++ b/src/cobra/io/web/cobrapy_repository.py @@ -1,6 +1,5 @@ """Provide functions for loading metabolic models from local package data.""" - import importlib_resources import cobra.data diff --git a/src/cobra/io/web/load.py b/src/cobra/io/web/load.py index 5244904ac..21bd619a7 100644 --- a/src/cobra/io/web/load.py +++ b/src/cobra/io/web/load.py @@ -1,6 +1,5 @@ """Provide a function ``load_model`` to access remote model repositories.""" - import gzip import logging from typing import TYPE_CHECKING, Iterable diff --git a/src/cobra/manipulation/delete.py b/src/cobra/manipulation/delete.py index 1fe8c0a4d..0ef6454f5 100644 --- a/src/cobra/manipulation/delete.py +++ b/src/cobra/manipulation/delete.py @@ -1,4 +1,5 @@ """Provide functions for pruning reactions, metabolites and genes.""" + import logging from ast import And, BoolOp, Name, NodeTransformer from functools import partial diff --git a/src/cobra/sampling/achr.py b/src/cobra/sampling/achr.py index e3d3e842e..7d56ee558 100644 --- a/src/cobra/sampling/achr.py +++ b/src/cobra/sampling/achr.py @@ -94,7 +94,7 @@ def __init__( thinning: int = 100, nproj: Optional[int] = None, seed: Optional[int] = None, - **kwargs + **kwargs, ) -> None: """Initialize a new ACHRSampler.""" super().__init__(model, thinning, nproj=nproj, seed=seed, **kwargs) diff --git a/src/cobra/sampling/optgp.py b/src/cobra/sampling/optgp.py index fad9ee4f7..97231c8e2 100644 --- a/src/cobra/sampling/optgp.py +++ b/src/cobra/sampling/optgp.py @@ -1,6 +1,5 @@ """Provide the OptGP sampler class and helper functions.""" - from typing import TYPE_CHECKING, Dict, Optional, Tuple import numpy as np @@ -110,10 +109,10 @@ def __init__( processes: Optional[int] = None, nproj: Optional[int] = None, seed: Optional[int] = None, - **kwargs + **kwargs, ) -> None: """Initialize a new OptGPSampler.""" - super().__init__(model, thinning, nproj=nproj, seed=seed, *kwargs) + super().__init__(model, thinning, nproj=nproj, seed=seed, **kwargs) self.generate_fva_warmup() if processes is None: diff --git a/src/cobra/summary/metabolite_summary.py b/src/cobra/summary/metabolite_summary.py index f9fdef4ac..3dbb03de8 100644 --- a/src/cobra/summary/metabolite_summary.py +++ b/src/cobra/summary/metabolite_summary.py @@ -1,6 +1,5 @@ """Provide the metabolite summary class.""" - import logging from operator import attrgetter from textwrap import shorten diff --git a/src/cobra/summary/model_summary.py b/src/cobra/summary/model_summary.py index 832fe6f15..7ee3ecc1c 100644 --- a/src/cobra/summary/model_summary.py +++ b/src/cobra/summary/model_summary.py @@ -1,6 +1,5 @@ """Provide the model summary class.""" - import logging from operator import attrgetter from typing import TYPE_CHECKING, Dict, List, Optional, Union diff --git a/src/cobra/summary/reaction_summary.py b/src/cobra/summary/reaction_summary.py index a8e7f20ba..0d98b5bc5 100644 --- a/src/cobra/summary/reaction_summary.py +++ b/src/cobra/summary/reaction_summary.py @@ -1,6 +1,5 @@ """Provide the reaction summary class.""" - import logging from textwrap import dedent, shorten from typing import TYPE_CHECKING, Optional, Union diff --git a/src/cobra/summary/summary.py b/src/cobra/summary/summary.py index e7403b051..70bb55d40 100644 --- a/src/cobra/summary/summary.py +++ b/src/cobra/summary/summary.py @@ -1,6 +1,5 @@ """Provide the abstract base summary class.""" - import logging from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Optional, Union diff --git a/src/cobra/util/process_pool.py b/src/cobra/util/process_pool.py index 6b255427c..e977e3ce5 100644 --- a/src/cobra/util/process_pool.py +++ b/src/cobra/util/process_pool.py @@ -1,6 +1,5 @@ """Provide a process pool with enhanced performance on Windows.""" - import multiprocessing import os import pickle @@ -30,7 +29,7 @@ def __init__( initializer: Optional[Callable] = None, initargs: Tuple = (), maxtasksperchild: Optional[int] = None, - **kwargs + **kwargs, ) -> None: """ Initialize a process pool. diff --git a/tests/test_core/test_gene.py b/tests/test_core/test_gene.py index c79e25d84..39ff74e2d 100644 --- a/tests/test_core/test_gene.py +++ b/tests/test_core/test_gene.py @@ -1,6 +1,5 @@ """Test functions of gene.py .""" - from cobra.core import Model diff --git a/tests/test_core/test_group.py b/tests/test_core/test_group.py index 9768ca82f..a5ed210e1 100644 --- a/tests/test_core/test_group.py +++ b/tests/test_core/test_group.py @@ -1,6 +1,5 @@ """Test functions of group via model.py.""" - import pytest from cobra import Model diff --git a/tests/test_flux_analysis/test_deletion.py b/tests/test_flux_analysis/test_deletion.py index fb462845a..11b8a9e8b 100644 --- a/tests/test_flux_analysis/test_deletion.py +++ b/tests/test_flux_analysis/test_deletion.py @@ -1,6 +1,5 @@ """Test functionalities of reaction and gene deletions.""" - import math import os from typing import Callable, List diff --git a/tests/test_medium/test_boundary_types.py b/tests/test_medium/test_boundary_types.py index 792a71513..2299d5165 100644 --- a/tests/test_medium/test_boundary_types.py +++ b/tests/test_medium/test_boundary_types.py @@ -1,6 +1,5 @@ """Test functionalities of boundary type detection functions.""" - import pytest from cobra.core import Metabolite, Model, Reaction diff --git a/tests/test_summary/test_metabolite_summary.py b/tests/test_summary/test_metabolite_summary.py index 1f543bfd0..7339228fc 100644 --- a/tests/test_summary/test_metabolite_summary.py +++ b/tests/test_summary/test_metabolite_summary.py @@ -1,6 +1,5 @@ """Unit test the MetaboliteSummary class.""" - import pytest from cobra.flux_analysis import flux_variability_analysis, pfba diff --git a/tests/test_summary/test_model_summary.py b/tests/test_summary/test_model_summary.py index c05e8ab00..479581fe6 100644 --- a/tests/test_summary/test_model_summary.py +++ b/tests/test_summary/test_model_summary.py @@ -1,6 +1,5 @@ """Unit test the model summary.""" - import pytest from cobra.flux_analysis import flux_variability_analysis, pfba diff --git a/tests/test_summary/test_reaction_summary.py b/tests/test_summary/test_reaction_summary.py index 8926285a2..8542301dc 100644 --- a/tests/test_summary/test_reaction_summary.py +++ b/tests/test_summary/test_reaction_summary.py @@ -1,6 +1,5 @@ """Unit test the ReactionSummary class.""" - import pytest from cobra.flux_analysis import flux_variability_analysis, pfba diff --git a/tests/test_util/test_process_pool.py b/tests/test_util/test_process_pool.py index 3c60a7570..40f174960 100644 --- a/tests/test_util/test_process_pool.py +++ b/tests/test_util/test_process_pool.py @@ -1,6 +1,5 @@ """Test the behaviour of the ProcessPool class.""" - import os from typing import Iterable, Tuple