Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: update ruff #45

Merged
merged 7 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: detect-aws-credentials
args: [ --allow-missing-credentials ]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0 # ruff version
rev: v0.8.6 # ruff version
hooks:
- id: ruff-format
- id: ruff
Expand Down
3 changes: 2 additions & 1 deletion analysis/speed_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"metadata": {},
"outputs": [],
"source": [
"from pyliftover import LiftOver \n",
"from pyliftover import LiftOver\n",
"\n",
"from agct import Converter"
]
},
Expand Down
31 changes: 27 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tests = [
]
dev = [
"maturin",
"ruff==0.5.0",
"ruff==0.8.6",
"pre-commit>=3.7.1",
]

Expand Down Expand Up @@ -88,10 +88,14 @@ select = [
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
"SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf
"SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
"PLC", # https://docs.astral.sh/ruff/rules/#convention-c
"PLE", # https://docs.astral.sh/ruff/rules/#error-e_1
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
Expand All @@ -110,6 +114,9 @@ fixable = [
"PT",
"RSE",
"SIM",
"PLC",
"PLE",
"TRY",
"PERF",
"FURB",
"RUF"
Expand All @@ -130,23 +137,39 @@ fixable = [
# E501 - line-too-long*
# W191 - tab-indentation*
# S321 - suspicious-ftp-lib-usage
# PLC0206 - dict-index-missing-items
# *ignored for compatibility with formatter
ignore = [
"ANN003", "ANN101", "ANN102",
"ANN003",
"D203", "D205", "D206", "D213", "D300", "D400", "D415",
"E111", "E114", "E117", "E501",
"W191",
"S321",
"PLC0206",
]

[tool.ruff.lint.per-file-ignores]
# ANN001 - missing-type-function-argument
# ANN2 - missing-return-type
# ANN102 - missing-type-cls
# D100 - undocumented-public-module
# D102 - undocumented-public-class
# D103 - undocumented-public-function
# S101 - assert
# B011 - assert-false
# INP001 - implicit-namespace-package
"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "B011", "INP001"]
"tests/*" = [
"ANN001",
"ANN2",
"D100",
"D102",
"D103",
"S101",
"B011",
"INP001"
]

[tool.ruff.lint.flake8-annotations]
mypy-init-return = true

[tool.ruff.format]
docstring-code-format = true
2 changes: 1 addition & 1 deletion src/agct/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from agct.converter import Converter, Genome, Strand

__all__ = ["Converter", "Strand", "Genome"]
__all__ = ["Converter", "Genome", "Strand"]
18 changes: 9 additions & 9 deletions src/agct/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ def __init__(

try:
self._converter = _core.Converter(chainfile)
except FileNotFoundError as e:
_logger.error("Unable to open chainfile located at %s", chainfile)
raise e
except _core.ChainfileError as e:
_logger.error("Error reading chainfile located at %s", chainfile)
raise e
except FileNotFoundError:
_logger.exception("Unable to open chainfile located at %s", chainfile)
raise
except _core.ChainfileError:
_logger.exception("Error reading chainfile located at %s", chainfile)
raise

@staticmethod
def _download_function_builder(from_db: Genome, to_db: Genome) -> Callable:
Expand Down Expand Up @@ -147,7 +147,7 @@ def convert_coordinate(
except _core.NoLiftoverError:
results = []
except _core.ChainfileError:
_logger.error(
_logger.exception(
"Encountered internal error while converting coordinates - is the chainfile invalid? (%s, %s, %s)",
chrom,
pos,
Expand All @@ -159,12 +159,12 @@ def convert_coordinate(
try:
pos = int(result[1])
except ValueError:
_logger.error("Got invalid position value in %s", result)
_logger.exception("Got invalid position value in %s", result)
continue
try:
strand = Strand(result[2])
except ValueError:
_logger.error("Got invalid Strand value in %s", result)
_logger.exception("Got invalid Strand value in %s", result)
continue
formatted_results.append((result[0], pos, strand))
return formatted_results
Loading