Skip to content

Commit

Permalink
Merge branch 'main' into improve-graph-app
Browse files Browse the repository at this point in the history
  • Loading branch information
rbasu101 committed Jan 13, 2025
2 parents 285b199 + 715c205 commit 949b7ea
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 22 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
hook:
- "end-of-file-fixer"
- "trailing-whitespace"
- "mixed-line-ending"
- cmd: "end-of-file-fixer"
- cmd: "trailing-whitespace"
- cmd: "mixed-line-ending"
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
Expand Down
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
26 changes: 18 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,9 @@ branch = true

[tool.ruff]
src = ["src"]
exclude = ["docs/source/conf.py"]
exclude = [
"docs/source/conf.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 +112,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 +138,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 +159,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 +182,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 @@ -14,15 +14,15 @@
from .network_graph import create_network, generate_cytoscape

__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",
"create_network",
"generate_cytoscape",
]
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

0 comments on commit 949b7ea

Please sign in to comment.