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

Merged
merged 4 commits into from
Jan 9, 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 @@ -13,7 +13,7 @@ repos:
- id: mixed-line-ending
args: [ --fix=lf ]
- 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
27 changes: 19 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ tests = [
"pytest-benchmark",
"requests_mock",
]
dev = ["pre-commit>=3.7.1", "ruff==0.5.0"]
dev = [
"pre-commit>=3.7.1",
"ruff==0.8.6",
]
docs = [
"sphinx==6.1.3",
"sphinx-autodoc-typehints==1.22.0",
Expand Down Expand Up @@ -80,7 +83,10 @@ branch = true

[tool.ruff]
src = ["src"]
exclude = ["docs/source/conf.py", "tests/test_graph_app.py"]
exclude = [
"docs/source/conf.py",
"tests/test_graph_app.py",
]
lint.select = [
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
Expand All @@ -107,10 +113,14 @@ lint.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 @@ -129,14 +139,15 @@ lint.fixable = [
"PT",
"RSE",
"SIM",
"PLC",
"PLE",
"TRY",
"PERF",
"FURB",
"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 @@ -149,18 +160,19 @@ lint.fixable = [
# E117 - over-indented*
# E501 - line-too-long*
# W191 - tab-indentation*
# PLC0206 - dict-index-missing-items
# *ignored for compatibility with formatter
lint.ignore = [
"ANN003", "ANN101", "ANN102",
"ANN003",
"D203", "D205", "D206", "D213", "D300", "D400", "D415",
"E111", "E114", "E117", "E501",
"W191",
"E722"
"E722",
"PLC0206",
]

[tool.ruff.lint.per-file-ignores]
# ANN001 - missing-type-function-argument
# ANN102 - missing-type-cls
# ANN2 - missing-return-type
# D100 - undocumented-public-module
# D101 - undocumented-public-class
Expand All @@ -171,7 +183,6 @@ lint.ignore = [
# INP001 - implicit-namespace-package
"tests/*" = [
"ANN001",
"ANN102",
"ANN2",
"S101",
"B011",
Expand Down
10 changes: 5 additions & 5 deletions src/dgipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
from .graph_app import generate_app

__all__ = [
"SourceType",
"generate_app",
"get_all_genes",
"get_categories",
"get_drug_applications",
"get_drugs",
"get_genes",
"get_interactions",
"get_categories",
"get_sources",
"SourceType",
"get_all_genes",
"get_drug_applications",
"generate_app",
]
3 changes: 2 additions & 1 deletion src/dgipy/dgidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def get_interactions(
:param approved: filter option for approved interactions
:param api_url: API endpoint for GraphQL request
:return: interaction results for terms
:raise ValueError: if invalid `search` arg used
"""
params: dict[str, str | int | bool | list[str]] = {"names": terms}
if immunotherapy is not None:
Expand All @@ -179,7 +180,7 @@ def get_interactions(
results = raw_results["drugs"]["nodes"]
else:
msg = "Search type must be specified using: search='drugs' or search='genes'"
raise Exception(msg)
raise ValueError(msg)
output = {
"gene_name": [],
"gene_concept_id": [],
Expand Down
2 changes: 1 addition & 1 deletion src/dgipy/queries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def query(self) -> DocumentNode:


__all__ = [
"get_all_genes",
"get_all_drugs",
"get_all_genes",
"get_drug_applications",
"get_drugs",
"get_gene_categories",
Expand Down
3 changes: 2 additions & 1 deletion src/dgipy/vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ def annotate(filepath: Path, contig: str) -> pd.DataFrame:
:param filepath: link to a valid VCF file
:param contig: specified chromosome (i.e. chr7)
:return: Dataframe of drug-gene interactions
:raise TypeError: if filepath arg is not of type ``Path``
"""
if not isinstance(filepath, Path):
msg = "Filepath argument must be a valid pathlib.Path object"
raise ValueError(msg)
raise TypeError(msg)

# Open VCF file
records = _process_vcf(filepath, contig)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dgidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_get_drug_applications(fixtures_dir, set_up_graphql_mock: Callable):
assert results["drug_dosage_form"][0] == ProductDosageForm.TABLET


@pytest.mark.performance()
@pytest.mark.performance
def test_get_interactions_benchmark(benchmark):
"""Skipped by default -- call pytest with `--performance` flag to run.

Expand Down
Loading