Skip to content

Commit

Permalink
pre-commit: switch to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Feb 28, 2023
1 parent abbd3d2 commit 883eedb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 35 deletions.
16 changes: 4 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,15 @@ repos:
- id: mixed-line-ending
- id: check-case-conflict
- id: check-yaml
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.253
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
- id: ruff
args: ["--fix"]
- repo: https://github.com/python/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
hooks:
Expand Down
9 changes: 5 additions & 4 deletions nxontology/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _pronto_edges_for_term(
Extract edges including "is a" relationships for a Pronto term.
https://github.com/althonos/pronto/issues/119#issuecomment-956541286
"""
rels = list()
rels = []
source_id = cast(Node, term.id)
for target in term.superclasses(distance=1, with_self=False):
rels.append((source_id, cast(Node, target.id), default_rel_type))
Expand Down Expand Up @@ -160,7 +160,7 @@ def pronto_to_multidigraph(

def multidigraph_to_digraph(
graph: nx.MultiDiGraph,
rel_types: list[str] | None = None,
rel_types: list[str] | tuple[str, ...] | None = None,
reverse: bool = True,
reduce: bool = False,
) -> nx.DiGraph:
Expand Down Expand Up @@ -219,13 +219,14 @@ def read_gene_ontology(
release: str = "current",
source_file: str = "go-basic.json.gz",
rel_types: list[str]
| None = [
| tuple[str, ...]
| None = (
"is a",
"part of",
"regulates",
"negatively regulates",
"positively regulates",
],
),
reduce: bool = True,
) -> NXOntology[str]:
"""
Expand Down
4 changes: 2 additions & 2 deletions nxontology/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def compute_similarities(
self,
source_nodes: Iterable[Node],
target_nodes: Iterable[Node],
ic_metrics: list[str] = ["intrinsic_ic_sanchez"],
ic_metrics: list[str] | tuple[str, ...] = ("intrinsic_ic_sanchez",),
) -> Iterable[dict[str, Any]]:
"""
Yield similarity metric dictionaries for all combinations of
Expand All @@ -218,7 +218,7 @@ def node_info(self, node: Node) -> Node_Info[Node]:

@cache_on_frozen
def _get_name_to_node_info(self) -> dict[str, Node_Info[Node]]:
name_to_node_info: dict[str, Node_Info[Node]] = dict()
name_to_node_info: dict[str, Node_Info[Node]] = {}
for node in self.graph:
info = self.node_info(node)
name = info.name
Expand Down
30 changes: 21 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
# including this section enables version inference

# https://pycqa.github.io/isort/docs/configuration/config_files.html
[tool.isort]
profile = "black"
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 88

[tool.black]
target-version = ['py38', 'py39', 'py310', 'py311']

[tool.ruff]
target-version = "py38"
line-length = 88
ignore = [
"E402", # ignore import-at-top-of-file violations
"E501", # ignore line-length violations
"F811", # ignore redefinition of a function
"B019", # ignore functools cache/lru_cache
"UP030", # allow explicit positional string formatting
]
select = [
"B", # flake8-bugbear
"C", # flake8-comprehensions
"C90", # mccabe
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"W", # pycode warnings
]

# https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file
[tool.mypy]
python_version = "3.8"
Expand Down
8 changes: 0 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,3 @@ dev =
pytest
viz =
pygraphviz

[flake8]
ignore =
E203
E402
E501
E731
W503

0 comments on commit 883eedb

Please sign in to comment.