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 #215

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -12,7 +12,7 @@ repos:
- id: mixed-line-ending
args: [ --fix=lf ]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
rev: v0.8.4
hooks:
- id: ruff-format
- id: ruff
Expand Down
16 changes: 9 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dynamic=["version"]

[project.optional-dependencies]
tests = ["pytest", "pytest-cov", "pytest-asyncio"]
dev = ["pre-commit>=3.7.1", "pytest", "pytest-cov", "pytest-asyncio", "ruff==0.5.0"]
dev = ["pre-commit>=3.7.1", "pytest", "pytest-cov", "pytest-asyncio", "ruff==0.8.4"]
docs = [
"sphinx==6.1.3",
"sphinx-autodoc-typehints==1.22.0",
Expand Down Expand Up @@ -104,10 +104,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 @@ -131,8 +135,6 @@ fixable = [
"RUF",
]
# ANN003 - missing-type-kwargs
# ANN101 - missing-type-self
# ANN102 - missing-type-cls
# D203 - one-blank-line-before-class
# D205 - blank-line-after-summary
# D206 - indent-with-spaces*
Expand All @@ -146,18 +148,19 @@ 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
# ANN102 - missing-type-cls
# ANN2 - missing-return-type
# ANN201 - missing-return-type-undocumented-public-function
# D100 - undocumented-public-module
Expand All @@ -172,15 +175,14 @@ ignore = [
"tests/*" = [
"ANN001",
"ANN2",
"ANN102",
"D100",
"D102",
"S101",
"B011",
"INP001",
"SLF001"
]
"src/fusor/models.py" = ["ANN201", "N803", "N805", "N815", "ANN001", "ANN2", "ANN102"]
"src/fusor/models.py" = ["ANN201", "N803", "N805", "N815", "ANN001", "ANN2"]
"scripts/*" = ["INP001"]

[tool.ruff.lint.flake8-annotations]
Expand Down
2 changes: 1 addition & 1 deletion src/fusor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from fusor.fusor import FUSOR

__all__ = ["__version__", "FUSOR"]
__all__ = ["FUSOR", "__version__"]


try:
Expand Down
2 changes: 1 addition & 1 deletion src/fusor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def _access_object_attr(
return obj.get(attr_name)
else:
msg = "Unrecognized type, should only pass entities with properties"
raise ValueError(msg)
raise ValueError(msg) # noqa: TRY004

@classmethod
def _fetch_gene_id(
Expand Down
2 changes: 1 addition & 1 deletion src/fusor/nomenclature.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def generate_nomenclature(fusion: Fusion, sr: SeqRepo) -> str:
):
parts.append(gene_nomenclature(element))
else:
raise ValueError
raise ValueError # noqa: TRY004
if (
isinstance(fusion, AssayedFusion)
and fusion.assay
Expand Down
4 changes: 2 additions & 2 deletions src/fusor/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ async def check_data_resources(
_logger.error("Health check failed: gene DB is incompletely populated")
else:
gene_status = True
except Exception as e:
_logger.error("Encountered error while creating gene DB: %s", e)
except Exception:
_logger.exception("Encountered error while initializing gene DB")
return FusorDataResourceStatus(
cool_seq_tool=all(cst_status), gene_normalizer=gene_status
)
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def exhaustive_example(alk_gene, braf_gene, tpm3_gene):
}


@pytest.fixture()
@pytest.fixture
def fusion_example():
"""Create test fixture for a fake fusion without additional property expansion."""
return {
Expand Down
4 changes: 2 additions & 2 deletions tests/test_fusor.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def mane_transcript_segment_element():
return TranscriptSegmentElement(**params)


@pytest.fixture()
@pytest.fixture
def fusion_ensg_sequence_id(templated_sequence_element_ensg):
"""Create fixture using Ensemble gene ID."""
params = {
Expand Down Expand Up @@ -451,7 +451,7 @@ def test_fusion(
assert msg in str(excinfo.value)


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_transcript_segment_element(
fusor_instance, transcript_segment_element, mane_transcript_segment_element
):
Expand Down
16 changes: 8 additions & 8 deletions tests/test_translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_valid_fusion_partners(translator_instance):
assert not partners_check


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_jaffa(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
):
Expand Down Expand Up @@ -176,7 +176,7 @@ async def test_jaffa(
assert jaffa_fusor_nonexonic.structure == fusion_data_example_nonexonic.structure


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_star_fusion(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
):
Expand Down Expand Up @@ -218,7 +218,7 @@ async def test_star_fusion(
)


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_fusion_catcher(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
):
Expand Down Expand Up @@ -261,7 +261,7 @@ async def test_fusion_catcher(
)


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_fusion_map(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
):
Expand Down Expand Up @@ -307,7 +307,7 @@ async def test_fusion_map(
)


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_arriba(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
):
Expand Down Expand Up @@ -371,7 +371,7 @@ async def test_arriba(
assert arriba_fusor_nonexonic.structure == fusion_data_example_nonexonic.structure


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_cicero(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
):
Expand Down Expand Up @@ -475,7 +475,7 @@ async def test_cicero(
)


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_enfusion(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
):
Expand Down Expand Up @@ -519,7 +519,7 @@ async def test_enfusion(
assert enfusion_fusor_nonexonic.structure == fusion_data_example_nonexonic.structure


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_genie(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
):
Expand Down
Loading