Skip to content

Commit 8cd8bc7

Browse files
authored
style: update ruff (#45)
1 parent 445b377 commit 8cd8bc7

File tree

5 files changed

+40
-16
lines changed

5 files changed

+40
-16
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: detect-aws-credentials
1111
args: [ --allow-missing-credentials ]
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.5.0 # ruff version
13+
rev: v0.8.6 # ruff version
1414
hooks:
1515
- id: ruff-format
1616
- id: ruff

analysis/speed_test.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18-
"from pyliftover import LiftOver \n",
18+
"from pyliftover import LiftOver\n",
19+
"\n",
1920
"from agct import Converter"
2021
]
2122
},

pyproject.toml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tests = [
3131
]
3232
dev = [
3333
"maturin",
34-
"ruff==0.5.0",
34+
"ruff==0.8.6",
3535
"pre-commit>=3.7.1",
3636
]
3737

@@ -88,10 +88,14 @@ select = [
8888
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
8989
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
9090
"SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf
91+
"SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
9192
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
9293
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
9394
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
9495
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
96+
"PLC", # https://docs.astral.sh/ruff/rules/#convention-c
97+
"PLE", # https://docs.astral.sh/ruff/rules/#error-e_1
98+
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
9599
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
96100
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
97101
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
@@ -110,6 +114,9 @@ fixable = [
110114
"PT",
111115
"RSE",
112116
"SIM",
117+
"PLC",
118+
"PLE",
119+
"TRY",
113120
"PERF",
114121
"FURB",
115122
"RUF"
@@ -130,23 +137,39 @@ fixable = [
130137
# E501 - line-too-long*
131138
# W191 - tab-indentation*
132139
# S321 - suspicious-ftp-lib-usage
140+
# PLC0206 - dict-index-missing-items
133141
# *ignored for compatibility with formatter
134142
ignore = [
135-
"ANN003", "ANN101", "ANN102",
143+
"ANN003",
136144
"D203", "D205", "D206", "D213", "D300", "D400", "D415",
137145
"E111", "E114", "E117", "E501",
138146
"W191",
139147
"S321",
148+
"PLC0206",
140149
]
141150

142151
[tool.ruff.lint.per-file-ignores]
143152
# ANN001 - missing-type-function-argument
144153
# ANN2 - missing-return-type
145-
# ANN102 - missing-type-cls
154+
# D100 - undocumented-public-module
155+
# D102 - undocumented-public-class
156+
# D103 - undocumented-public-function
146157
# S101 - assert
147158
# B011 - assert-false
148159
# INP001 - implicit-namespace-package
149-
"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "B011", "INP001"]
160+
"tests/*" = [
161+
"ANN001",
162+
"ANN2",
163+
"D100",
164+
"D102",
165+
"D103",
166+
"S101",
167+
"B011",
168+
"INP001"
169+
]
170+
171+
[tool.ruff.lint.flake8-annotations]
172+
mypy-init-return = true
150173

151174
[tool.ruff.format]
152175
docstring-code-format = true

src/agct/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
from agct.converter import Converter, Genome, Strand
44

5-
__all__ = ["Converter", "Strand", "Genome"]
5+
__all__ = ["Converter", "Genome", "Strand"]

src/agct/converter.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ def __init__(
9090

9191
try:
9292
self._converter = _core.Converter(chainfile)
93-
except FileNotFoundError as e:
94-
_logger.error("Unable to open chainfile located at %s", chainfile)
95-
raise e
96-
except _core.ChainfileError as e:
97-
_logger.error("Error reading chainfile located at %s", chainfile)
98-
raise e
93+
except FileNotFoundError:
94+
_logger.exception("Unable to open chainfile located at %s", chainfile)
95+
raise
96+
except _core.ChainfileError:
97+
_logger.exception("Error reading chainfile located at %s", chainfile)
98+
raise
9999

100100
@staticmethod
101101
def _download_function_builder(from_db: Genome, to_db: Genome) -> Callable:
@@ -147,7 +147,7 @@ def convert_coordinate(
147147
except _core.NoLiftoverError:
148148
results = []
149149
except _core.ChainfileError:
150-
_logger.error(
150+
_logger.exception(
151151
"Encountered internal error while converting coordinates - is the chainfile invalid? (%s, %s, %s)",
152152
chrom,
153153
pos,
@@ -159,12 +159,12 @@ def convert_coordinate(
159159
try:
160160
pos = int(result[1])
161161
except ValueError:
162-
_logger.error("Got invalid position value in %s", result)
162+
_logger.exception("Got invalid position value in %s", result)
163163
continue
164164
try:
165165
strand = Strand(result[2])
166166
except ValueError:
167-
_logger.error("Got invalid Strand value in %s", result)
167+
_logger.exception("Got invalid Strand value in %s", result)
168168
continue
169169
formatted_results.append((result[0], pos, strand))
170170
return formatted_results

0 commit comments

Comments
 (0)