From 4658513559e9e35a2074902c1ae692c85707c317 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 7 Aug 2024 09:43:13 -0400 Subject: [PATCH] style: update ruff (#40) --- .pre-commit-config.yaml | 2 +- pyproject.toml | 35 +++++++++++++------ src/wags_tails/__init__.py | 1 + src/wags_tails/base_source.py | 7 ++-- src/wags_tails/chembl.py | 1 + src/wags_tails/chemidplus.py | 3 +- src/wags_tails/custom.py | 7 ++-- src/wags_tails/do.py | 1 + src/wags_tails/drugbank.py | 8 ++--- src/wags_tails/drugsatfda.py | 3 +- src/wags_tails/ensembl.py | 1 + src/wags_tails/ensembl_transcript_mappings.py | 2 +- src/wags_tails/guide_to_pharmacology.py | 5 +-- src/wags_tails/hemonc.py | 11 +++--- src/wags_tails/hgnc.py | 3 +- src/wags_tails/mondo.py | 6 ++-- src/wags_tails/ncbi.py | 5 +-- src/wags_tails/ncbi_lrg_refseqgene.py | 3 +- src/wags_tails/ncbi_mane_summary.py | 1 + src/wags_tails/ncit.py | 1 + src/wags_tails/oncotree.py | 3 +- src/wags_tails/rxnorm.py | 1 + src/wags_tails/utils/downloads.py | 27 +++++++------- src/wags_tails/utils/storage.py | 1 + src/wags_tails/utils/versioning.py | 1 + tests/conftest.py | 1 + tests/test_base.py | 1 + tests/test_chembl.py | 1 + tests/test_chemidplus.py | 1 + tests/test_custom.py | 1 + tests/test_do.py | 6 ++-- tests/test_drugbank.py | 4 +-- tests/test_drugsatfda.py | 4 +-- tests/test_ensembl.py | 1 + tests/test_ensembl_transcript_mappings.py | 1 + tests/test_gtop.py | 4 +-- tests/test_hemonc.py | 4 +-- tests/test_hgnc.py | 1 + tests/test_mondo.py | 6 ++-- tests/test_ncbi.py | 1 + tests/test_ncbi_lrg_refseqgene.py | 1 + tests/test_ncbi_mane_summary.py | 1 + tests/test_ncit.py | 1 + tests/test_oncotree.py | 6 ++-- tests/test_rxnorm.py | 4 +-- 45 files changed, 119 insertions(+), 70 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 43afb3b..4b6b29c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.0 + rev: v0.5.0 # ruff version hooks: - id: ruff-format - id: ruff diff --git a/pyproject.toml b/pyproject.toml index 54d7f4b..7b914f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ [project.optional-dependencies] test = ["pytest>=6.0", "pytest-cov", "requests-mock"] -dev = ["pre-commit", "ruff==0.2.0"] +dev = ["pre-commit", "ruff==0.5.0"] docs = [ "sphinx==6.1.3", "sphinx-autodoc-typehints==1.22.0", @@ -84,16 +84,22 @@ select = [ "DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz "T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz "EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em + "LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log "G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g + "INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp "PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie "T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20 "PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt "Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q "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 "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 + "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 ] fixable = [ @@ -104,16 +110,20 @@ fixable = [ "ANN", "B", "C4", + "LOG", "G", "PIE", "PT", "RSE", "SIM", + "PERF", + "FURB", "RUF" ] -# ANN101 - missing-type-self # 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* @@ -129,7 +139,7 @@ fixable = [ # S321 - suspicious-ftp-lib-usage # *ignored for compatibility with formatter ignore = [ - "ANN101", "ANN003", + "ANN003", "ANN101", "ANN102", "D203", "D205", "D206", "D213", "D300", "D400", "D415", "E111", "E114", "E117", "E501", "W191", @@ -139,15 +149,20 @@ ignore = [ [tool.ruff.lint.per-file-ignores] # ANN001 - missing-type-function-argument # ANN2 - missing-return-type -# ANN201 - Missing type annotation -# ANN102 - missing-type-cls -# N805 - invalid-first-argument-name-for-method -# PT018 - pytest-composite-assertion # S101 - assert -"tests/*" = ["ANN001", "ANN102", "ANN2", "S101"] +# B011 - assert-false +# INP001 - implicit-namespace-package +# PT018 - pytest-composite-assertion +# ARG001 - unused-function-argument +# ARG005 - unused-lambda-argument +# T201 - print +"tests/*" = ["ANN001", "ANN2", "S101", "B011", "INP001"] "tests/test_hemonc.py" = ["PT018"] "tests/test_gtop.py" = ["PT018"] "tests/test_do.py" = ["PT018"] -"*__init__.py" = ["F401"] -"src/wags_tails/base_source.py" = ["ANN102"] +"tests/test_custom.py" = ["ARG001", "ARG005"] "src/wags_tails/utils/downloads.py" = ["T201"] + + +[tool.ruff.format] +docstring-code-format = true diff --git a/src/wags_tails/__init__.py b/src/wags_tails/__init__.py index 9b8dc28..971a229 100644 --- a/src/wags_tails/__init__.py +++ b/src/wags_tails/__init__.py @@ -1,4 +1,5 @@ """Data acquisition tools for Wagnerds.""" + from .base_source import DataSource, RemoteDataError from .chembl import ChemblData from .chemidplus import ChemIDplusData diff --git a/src/wags_tails/base_source.py b/src/wags_tails/base_source.py index 3567c80..4063dea 100644 --- a/src/wags_tails/base_source.py +++ b/src/wags_tails/base_source.py @@ -3,11 +3,12 @@ All source classes should inherit - directly or indirectly - from ``DataSource``. Each class defined here is an ``abstract base class`` and cannot be instantiated directly. """ + import abc import datetime import logging +from collections.abc import Generator from pathlib import Path -from typing import Generator, Optional, Tuple import requests @@ -33,7 +34,7 @@ class DataSource(abc.ABC): _filetype: str _versioned: bool = True - def __init__(self, data_dir: Optional[Path] = None, silent: bool = True) -> None: + def __init__(self, data_dir: Path | None = None, silent: bool = True) -> None: """Set common class parameters. :param data_dir: direct location to store data files in, if specified. See @@ -71,7 +72,7 @@ def _download_data(self, version: str, outfile: Path) -> None: def get_latest( self, from_local: bool = False, force_refresh: bool = False - ) -> Tuple[Path, str]: + ) -> tuple[Path, str]: """Get path to latest version of data. Provides logic for both versioned and unversioned data here, rather than in the diff --git a/src/wags_tails/chembl.py b/src/wags_tails/chembl.py index 45a3f85..dc085f6 100644 --- a/src/wags_tails/chembl.py +++ b/src/wags_tails/chembl.py @@ -1,4 +1,5 @@ """Provide source fetching for ChEMBL.""" + import fnmatch import re import tarfile diff --git a/src/wags_tails/chemidplus.py b/src/wags_tails/chemidplus.py index 673124c..6eaaace 100644 --- a/src/wags_tails/chemidplus.py +++ b/src/wags_tails/chemidplus.py @@ -1,4 +1,5 @@ """Provide source fetching for ChemIDplus.""" + import datetime import re from pathlib import Path @@ -38,7 +39,7 @@ def _get_latest_version() -> str: .strftime(DATE_VERSION_PATTERN) ) - def _download_data(self, version: str, outfile: Path) -> None: + def _download_data(self, version: str, outfile: Path) -> None: # noqa: ARG002 """Download data file to specified location. ChemIDplus data is no longer updated, so versioning is irrelevant. diff --git a/src/wags_tails/custom.py b/src/wags_tails/custom.py index d5be4d7..bcf781e 100644 --- a/src/wags_tails/custom.py +++ b/src/wags_tails/custom.py @@ -9,8 +9,9 @@ The :ref:`documentation ` provides more explanation and an in-depth example. """ + +from collections.abc import Callable from pathlib import Path -from typing import Callable, Optional from .base_source import DataSource @@ -24,8 +25,8 @@ def __init__( filetype: str, latest_version_cb: Callable[[], str], download_cb: Callable[[str, Path], None], - data_dir: Optional[Path] = None, - file_name: Optional[str] = None, + data_dir: Path | None = None, + file_name: str | None = None, versioned: bool = True, silent: bool = False, ) -> None: diff --git a/src/wags_tails/do.py b/src/wags_tails/do.py index 8eff946..725b72f 100644 --- a/src/wags_tails/do.py +++ b/src/wags_tails/do.py @@ -1,4 +1,5 @@ """Provide source fetching for Human Disease Ontology.""" + import datetime import tarfile from pathlib import Path diff --git a/src/wags_tails/drugbank.py b/src/wags_tails/drugbank.py index e1dcded..13c6250 100644 --- a/src/wags_tails/drugbank.py +++ b/src/wags_tails/drugbank.py @@ -1,7 +1,7 @@ """Provide source fetching for DrugBank.""" + import logging from pathlib import Path -from typing import Tuple import requests @@ -19,7 +19,7 @@ class DrugBankData(DataSource): _filetype = "csv" @staticmethod - def _get_latest_version() -> Tuple[str, str]: + def _get_latest_version() -> tuple[str, str]: """Retrieve latest version value :return: latest release value and base download URL @@ -35,7 +35,7 @@ def _get_latest_version() -> Tuple[str, str]: msg = "Unable to parse latest DrugBank version number from releases API endpoint" raise RemoteDataError(msg) from e - def _get_latest_local_file(self, glob: str) -> Tuple[Path, str]: + def _get_latest_local_file(self, glob: str) -> tuple[Path, str]: """Get most recent locally-available file. DrugBank uses versioning that isn't easily sortable by default so we have to use some extra magic. @@ -72,7 +72,7 @@ def _download_data(self, url: str, outfile: Path) -> None: def get_latest( self, from_local: bool = False, force_refresh: bool = False - ) -> Tuple[Path, str]: + ) -> tuple[Path, str]: """Get path to latest version of data, and its version value :param from_local: if True, use latest available local file diff --git a/src/wags_tails/drugsatfda.py b/src/wags_tails/drugsatfda.py index 34ea124..d8d8492 100644 --- a/src/wags_tails/drugsatfda.py +++ b/src/wags_tails/drugsatfda.py @@ -1,4 +1,5 @@ """Provide source fetching for Drugs@FDA.""" + import datetime from pathlib import Path @@ -38,7 +39,7 @@ def _get_latest_version() -> str: .strftime(DATE_VERSION_PATTERN) ) - def _download_data(self, version: str, outfile: Path) -> None: + def _download_data(self, version: str, outfile: Path) -> None: # noqa: ARG002 """Download latest data file to specified location. :param version: version to acquire diff --git a/src/wags_tails/ensembl.py b/src/wags_tails/ensembl.py index ece3a25..699da1f 100644 --- a/src/wags_tails/ensembl.py +++ b/src/wags_tails/ensembl.py @@ -1,4 +1,5 @@ """Provide data management for Ensembl genomic data.""" + from pathlib import Path import requests diff --git a/src/wags_tails/ensembl_transcript_mappings.py b/src/wags_tails/ensembl_transcript_mappings.py index 5ef3277..d61552a 100644 --- a/src/wags_tails/ensembl_transcript_mappings.py +++ b/src/wags_tails/ensembl_transcript_mappings.py @@ -14,7 +14,7 @@ class EnsemblTranscriptMappingData(UnversionedDataSource): _src_name = "ensembl_transcript_mappings" _filetype = "tsv" - def _download_data(self, version: str, outfile: Path) -> None: + def _download_data(self, version: str, outfile: Path) -> None: # noqa: ARG002 """Download data file to specified location. :param version: version to acquire diff --git a/src/wags_tails/guide_to_pharmacology.py b/src/wags_tails/guide_to_pharmacology.py index b71ad17..a4d5bd4 100644 --- a/src/wags_tails/guide_to_pharmacology.py +++ b/src/wags_tails/guide_to_pharmacology.py @@ -1,8 +1,9 @@ """Provide source fetching for Guide To Pharmacology.""" + import logging import re from pathlib import Path -from typing import NamedTuple, Tuple +from typing import NamedTuple import requests @@ -67,7 +68,7 @@ def _download_data(self, file_paths: GtoPLigandPaths) -> None: def get_latest( self, from_local: bool = False, force_refresh: bool = False - ) -> Tuple[GtoPLigandPaths, str]: + ) -> tuple[GtoPLigandPaths, str]: """Get path to latest version of data, and its version value :param from_local: if True, use latest available local file diff --git a/src/wags_tails/hemonc.py b/src/wags_tails/hemonc.py index 7af417c..68fa2c6 100644 --- a/src/wags_tails/hemonc.py +++ b/src/wags_tails/hemonc.py @@ -1,9 +1,10 @@ """Provide source fetching for HemOnc.""" + import logging import os import zipfile from pathlib import Path -from typing import NamedTuple, Tuple +from typing import NamedTuple import requests @@ -69,7 +70,7 @@ def _download_handler(self, dl_path: Path, file_paths: HemOncPaths) -> None: zip_ref.extract(file, path.parent) dl_path.unlink() - def _download_data(self, version: str, outfile_paths: HemOncPaths) -> None: + def _download_data(self, version: str, outfile_paths: HemOncPaths) -> None: # noqa: ARG002 """Download data file to specified location. :param version: version to acquire @@ -84,13 +85,13 @@ def _download_data(self, version: str, outfile_paths: HemOncPaths) -> None: self.data_dir, headers={"X-Dataverse-key": api_key}, # provide save_path arg for API consistency, but don't use it - handler=lambda dl_path, save_path: self._download_handler( + handler=lambda dl_path, save_path: self._download_handler( # noqa: ARG005 dl_path, outfile_paths ), tqdm_params=self._tqdm_params, ) - def _get_local_files(self) -> Tuple[HemOncPaths, str]: + def _get_local_files(self) -> tuple[HemOncPaths, str]: """Acquire locally-available data files. :return: HemOnc file paths and their version @@ -108,7 +109,7 @@ def _get_local_files(self) -> Tuple[HemOncPaths, str]: def get_latest( self, from_local: bool = False, force_refresh: bool = False - ) -> Tuple[HemOncPaths, str]: + ) -> tuple[HemOncPaths, str]: """Get path to latest version of data, and its version value :param from_local: if True, use latest available local file diff --git a/src/wags_tails/hgnc.py b/src/wags_tails/hgnc.py index f9c52e4..1118ee2 100644 --- a/src/wags_tails/hgnc.py +++ b/src/wags_tails/hgnc.py @@ -1,4 +1,5 @@ """Provide data fetching for HGNC.""" + import ftplib from pathlib import Path @@ -26,7 +27,7 @@ def _get_latest_version(self) -> str: timestamp = ftp.voidcmd(f"MDTM {self._directory_path}{self._host_filename}") return timestamp[4:12] - def _download_data(self, version: str, outfile: Path) -> None: + def _download_data(self, version: str, outfile: Path) -> None: # noqa: ARG002 """Download data file to specified location. :param version: version to acquire diff --git a/src/wags_tails/mondo.py b/src/wags_tails/mondo.py index d815ab0..a41dc84 100644 --- a/src/wags_tails/mondo.py +++ b/src/wags_tails/mondo.py @@ -1,8 +1,8 @@ """Provide source fetching for Mondo Disease Ontology.""" + import datetime import logging from pathlib import Path -from typing import Tuple import requests @@ -22,7 +22,7 @@ class MondoData(GitHubDataSource): _repo = "monarch-initiative/mondo" @staticmethod - def _get_latest_version() -> Tuple[str, str]: + def _get_latest_version() -> tuple[str, str]: """Retrieve latest version value, and download URL, from GitHub release data. :param asset_name: name of file asset, if needed @@ -71,7 +71,7 @@ def _download_data(self, version: str, outfile: Path) -> None: def get_latest( self, from_local: bool = False, force_refresh: bool = False - ) -> Tuple[Path, str]: + ) -> tuple[Path, str]: """Get path to latest version of data. Overwrite inherited method because final downloads depend on information gleaned from the version API call. diff --git a/src/wags_tails/ncbi.py b/src/wags_tails/ncbi.py index 9d740d5..fe490cb 100644 --- a/src/wags_tails/ncbi.py +++ b/src/wags_tails/ncbi.py @@ -1,9 +1,10 @@ """Provide data fetching for NCBI gene data sources.""" + import ftplib import logging import re from pathlib import Path -from typing import NamedTuple, Tuple +from typing import NamedTuple from wags_tails.base_source import DataSource, RemoteDataError from wags_tails.utils.downloads import download_ftp, handle_gzip @@ -142,7 +143,7 @@ def _download_data(self, file_paths: NcbiGenePaths) -> None: def get_latest( self, from_local: bool = False, force_refresh: bool = False - ) -> Tuple[NcbiGenePaths, str]: + ) -> tuple[NcbiGenePaths, str]: """Get path to latest version of data, and its version value :param from_local: if True, use latest available local file diff --git a/src/wags_tails/ncbi_lrg_refseqgene.py b/src/wags_tails/ncbi_lrg_refseqgene.py index 64ceeac..c426d9d 100644 --- a/src/wags_tails/ncbi_lrg_refseqgene.py +++ b/src/wags_tails/ncbi_lrg_refseqgene.py @@ -1,4 +1,5 @@ """Fetches NCBI LRG_RefSeqGene data.""" + import re from pathlib import Path @@ -36,7 +37,7 @@ def _get_latest_version(self) -> str: raise RemoteDataError(msg) return match[0].replace("-", "") - def _download_data(self, version: str, outfile: Path) -> None: + def _download_data(self, version: str, outfile: Path) -> None: # noqa: ARG002 """Download data file to specified location. :param version: version to acquire diff --git a/src/wags_tails/ncbi_mane_summary.py b/src/wags_tails/ncbi_mane_summary.py index 53bb56a..354f39c 100644 --- a/src/wags_tails/ncbi_mane_summary.py +++ b/src/wags_tails/ncbi_mane_summary.py @@ -1,4 +1,5 @@ """Fetches NCBI MANE summary data.""" + from pathlib import Path import requests diff --git a/src/wags_tails/ncit.py b/src/wags_tails/ncit.py index a53313d..5c9431c 100644 --- a/src/wags_tails/ncit.py +++ b/src/wags_tails/ncit.py @@ -1,4 +1,5 @@ """Provide source fetching for NCI Thesaurus.""" + import re from pathlib import Path diff --git a/src/wags_tails/oncotree.py b/src/wags_tails/oncotree.py index 6253230..74b5c88 100644 --- a/src/wags_tails/oncotree.py +++ b/src/wags_tails/oncotree.py @@ -1,4 +1,5 @@ """Provide access to Oncotree data.""" + import datetime from pathlib import Path @@ -39,7 +40,7 @@ def _get_latest_version(self) -> str: .strftime(DATE_VERSION_PATTERN) ) - def _download_data(self, version: str, outfile: Path) -> None: + def _download_data(self, version: str, outfile: Path) -> None: # noqa: ARG002 """Download data file to specified location. :param version: version to acquire diff --git a/src/wags_tails/rxnorm.py b/src/wags_tails/rxnorm.py index dd1c60b..a9da22f 100644 --- a/src/wags_tails/rxnorm.py +++ b/src/wags_tails/rxnorm.py @@ -1,4 +1,5 @@ """Provide source fetching for RxNorm.""" + import datetime import os import zipfile diff --git a/src/wags_tails/utils/downloads.py b/src/wags_tails/utils/downloads.py index 56d328b..d54023e 100644 --- a/src/wags_tails/utils/downloads.py +++ b/src/wags_tails/utils/downloads.py @@ -1,4 +1,5 @@ """Provide helper functions for downloading data.""" + import ftplib import gzip import logging @@ -6,8 +7,8 @@ import re import tempfile import zipfile +from collections.abc import Callable from pathlib import Path -from typing import Callable, Dict, Optional import requests from tqdm import tqdm @@ -51,8 +52,8 @@ def download_ftp( host_directory_path: str, host_filename: str, outfile_path: Path, - handler: Optional[Callable[[Path, Path], None]] = None, - tqdm_params: Optional[Dict] = None, + handler: Callable[[Path, Path], None] | None = None, + tqdm_params: dict | None = None, ) -> None: """Perform FTP download of remote data file. @@ -79,9 +80,10 @@ def download_ftp( file_size = ftp.size(host_filename) if not tqdm_params.get("disable"): print(f"Downloading {host}/{host_directory_path}{host_filename}...") - with dl_path.open("wb") as fp, tqdm( - total=file_size, **tqdm_params - ) as progress_bar: + with ( + dl_path.open("wb") as fp, + tqdm(total=file_size, **tqdm_params) as progress_bar, + ): def _cb(data: bytes) -> None: progress_bar.update(len(data)) @@ -98,9 +100,9 @@ def _cb(data: bytes) -> None: def download_http( url: str, outfile_path: Path, - headers: Optional[Dict] = None, - handler: Optional[Callable[[Path, Path], None]] = None, - tqdm_params: Optional[Dict] = None, + headers: dict | None = None, + handler: Callable[[Path, Path], None] | None = None, + tqdm_params: dict | None = None, ) -> None: """Perform HTTP download of remote data file. @@ -132,9 +134,10 @@ def download_http( print(f"Downloading {print_url}...") else: print(f"Downloading {os.path.basename(url)}...") # noqa: PTH119 - with dl_path.open("wb") as h, tqdm( - total=total_size, **tqdm_params - ) as progress_bar: + with ( + dl_path.open("wb") as h, + tqdm(total=total_size, **tqdm_params) as progress_bar, + ): for chunk in r.iter_content(chunk_size=8192): if chunk: h.write(chunk) diff --git a/src/wags_tails/utils/storage.py b/src/wags_tails/utils/storage.py index 01cefa4..308e41f 100644 --- a/src/wags_tails/utils/storage.py +++ b/src/wags_tails/utils/storage.py @@ -1,4 +1,5 @@ """Provide helpful functions for managing data storage.""" + import logging import os from pathlib import Path diff --git a/src/wags_tails/utils/versioning.py b/src/wags_tails/utils/versioning.py index bc3f301..facc586 100644 --- a/src/wags_tails/utils/versioning.py +++ b/src/wags_tails/utils/versioning.py @@ -1,4 +1,5 @@ """Basic utilities pertaining to data versioning.""" + import re from pathlib import Path diff --git a/tests/conftest.py b/tests/conftest.py index 1455fae..5640969 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Provide core testing utilities.""" + import shutil from pathlib import Path diff --git a/tests/test_base.py b/tests/test_base.py index 9048e23..1609945 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,4 +1,5 @@ """Test base class functions.""" + import os import tempfile from pathlib import Path diff --git a/tests/test_chembl.py b/tests/test_chembl.py index a77b914..cccec19 100644 --- a/tests/test_chembl.py +++ b/tests/test_chembl.py @@ -1,4 +1,5 @@ """Test ChEMBL data source.""" + from io import TextIOWrapper from pathlib import Path diff --git a/tests/test_chemidplus.py b/tests/test_chemidplus.py index 79d15ef..5a44aa6 100644 --- a/tests/test_chemidplus.py +++ b/tests/test_chemidplus.py @@ -1,4 +1,5 @@ """Test ChemIDplus data source.""" + from pathlib import Path import pytest diff --git a/tests/test_custom.py b/tests/test_custom.py index 09499f4..1746fe3 100644 --- a/tests/test_custom.py +++ b/tests/test_custom.py @@ -1,4 +1,5 @@ """Test custom data source.""" + from io import TextIOWrapper from pathlib import Path diff --git a/tests/test_do.py b/tests/test_do.py index c51e2f4..4d63638 100644 --- a/tests/test_do.py +++ b/tests/test_do.py @@ -1,8 +1,8 @@ """Test Disease Ontology data source.""" + import json from io import TextIOWrapper from pathlib import Path -from typing import Dict import pytest import requests_mock @@ -48,8 +48,8 @@ def latest_release_file(fixture_dir): def test_get_latest( do: DoData, data_dir, - versions_response: Dict, - latest_release_response: Dict, + versions_response: dict, + latest_release_response: dict, latest_release_file: TextIOWrapper, ): """Test DoData.get_latest()""" diff --git a/tests/test_drugbank.py b/tests/test_drugbank.py index 9b66331..eb6fd0f 100644 --- a/tests/test_drugbank.py +++ b/tests/test_drugbank.py @@ -1,7 +1,7 @@ """Test DrugBank data source.""" + import json from pathlib import Path -from typing import Dict import pytest import requests_mock @@ -40,7 +40,7 @@ def versions_response(fixture_dir): def test_get_latest( drugbank: DrugBankData, drugbank_data_dir: Path, - versions_response: Dict, + versions_response: dict, drugbank_file: str, ): """Test chemblData.get_latest()""" diff --git a/tests/test_drugsatfda.py b/tests/test_drugsatfda.py index d59e1d4..1d81e13 100644 --- a/tests/test_drugsatfda.py +++ b/tests/test_drugsatfda.py @@ -1,7 +1,7 @@ """Test Drugs@FDA data source.""" + import json from pathlib import Path -from typing import Dict import pytest import requests_mock @@ -40,7 +40,7 @@ def drugsatfda_file(fixture_dir): def test_get_latest( drugsatfda: DrugsAtFdaData, drugsatfda_data_dir: Path, - latest_release_response: Dict, + latest_release_response: dict, drugsatfda_file: str, ): """Test DrugsAtFdaData.get_latest()""" diff --git a/tests/test_ensembl.py b/tests/test_ensembl.py index cfd675e..73cc842 100644 --- a/tests/test_ensembl.py +++ b/tests/test_ensembl.py @@ -1,4 +1,5 @@ """Test Ensembl data source.""" + from pathlib import Path import pytest diff --git a/tests/test_ensembl_transcript_mappings.py b/tests/test_ensembl_transcript_mappings.py index 693346b..a7689bb 100644 --- a/tests/test_ensembl_transcript_mappings.py +++ b/tests/test_ensembl_transcript_mappings.py @@ -1,4 +1,5 @@ """Test Ensembl Transcript Mappings data source.""" + from pathlib import Path import pytest diff --git a/tests/test_gtop.py b/tests/test_gtop.py index 6e06790..2cfe1cc 100644 --- a/tests/test_gtop.py +++ b/tests/test_gtop.py @@ -1,6 +1,6 @@ """Test Guide to Pharmacology data source.""" + from pathlib import Path -from typing import Dict import pytest import requests_mock @@ -41,7 +41,7 @@ def gtop_ligand_file_paths(gtop_data_dir: Path): def test_get_latest( gtop_ligand: GToPLigandData, gtop_data_dir: Path, - latest_release_response: Dict, + latest_release_response: dict, gtop_ligand_file_paths: GtoPLigandPaths, ): """Test GToPLigandData.get_latest()""" diff --git a/tests/test_hemonc.py b/tests/test_hemonc.py index 4a90ab5..8c4498c 100644 --- a/tests/test_hemonc.py +++ b/tests/test_hemonc.py @@ -1,8 +1,8 @@ """Test HemOnc data source.""" + import json import os from pathlib import Path -from typing import Dict import pytest import requests_mock @@ -51,7 +51,7 @@ def hemonc_file_paths(hemonc_data_dir: Path): def test_get_latest( hemonc: HemOncData, hemonc_data_dir, - latest_release_response: Dict, + latest_release_response: dict, hemonc_file: str, hemonc_file_paths: HemOncPaths, ): diff --git a/tests/test_hgnc.py b/tests/test_hgnc.py index 80cec02..62f1fff 100644 --- a/tests/test_hgnc.py +++ b/tests/test_hgnc.py @@ -1,4 +1,5 @@ """Test HGNC data source.""" + from pathlib import Path import pytest diff --git a/tests/test_mondo.py b/tests/test_mondo.py index 3d6a37b..f7db62a 100644 --- a/tests/test_mondo.py +++ b/tests/test_mondo.py @@ -1,7 +1,7 @@ """Test Mondo data source.""" + import json from pathlib import Path -from typing import Dict import pytest import requests_mock @@ -47,7 +47,7 @@ def versions_response(fixture_dir): def test_get_latest( mondo: MondoData, mondo_data_dir: Path, - latest_release_response: Dict, + latest_release_response: dict, ): """Test MondoData.get_latest()""" with pytest.raises( @@ -99,7 +99,7 @@ def test_get_latest( assert m.call_count == 5 -def test_iterate_versions(mondo: MondoData, versions_response: Dict): +def test_iterate_versions(mondo: MondoData, versions_response: dict): """Test MondoData.iterate_versions()""" with requests_mock.Mocker() as m: m.get( diff --git a/tests/test_ncbi.py b/tests/test_ncbi.py index 3133825..8126675 100644 --- a/tests/test_ncbi.py +++ b/tests/test_ncbi.py @@ -1,4 +1,5 @@ """Test NCBI data source.""" + from pathlib import Path import pytest diff --git a/tests/test_ncbi_lrg_refseqgene.py b/tests/test_ncbi_lrg_refseqgene.py index dd17841..33e5949 100644 --- a/tests/test_ncbi_lrg_refseqgene.py +++ b/tests/test_ncbi_lrg_refseqgene.py @@ -1,4 +1,5 @@ """Test NCBI LRG_RefSeqGene data source.""" + from pathlib import Path import pytest diff --git a/tests/test_ncbi_mane_summary.py b/tests/test_ncbi_mane_summary.py index 81f4114..db8011a 100644 --- a/tests/test_ncbi_mane_summary.py +++ b/tests/test_ncbi_mane_summary.py @@ -1,4 +1,5 @@ """Test NCBI MANE summary data.""" + from pathlib import Path import pytest diff --git a/tests/test_ncit.py b/tests/test_ncit.py index 8f4b57e..6671f13 100644 --- a/tests/test_ncit.py +++ b/tests/test_ncit.py @@ -1,4 +1,5 @@ """Test NCIt data source.""" + from io import TextIOWrapper from pathlib import Path diff --git a/tests/test_oncotree.py b/tests/test_oncotree.py index ec236f2..9f6c487 100644 --- a/tests/test_oncotree.py +++ b/tests/test_oncotree.py @@ -1,7 +1,7 @@ """Test OncoTree data source.""" + import json from pathlib import Path -from typing import Dict import pytest import requests_mock @@ -40,8 +40,8 @@ def oncotree_tree(fixture_dir): def test_get_latest( oncotree: OncoTreeData, data_dir: Path, - oncotree_versions_response: Dict, - oncotree_tree: Dict, + oncotree_versions_response: dict, + oncotree_tree: dict, ): """Test chemblData.get_latest()""" with pytest.raises( diff --git a/tests/test_rxnorm.py b/tests/test_rxnorm.py index d8879c7..e5cd6af 100644 --- a/tests/test_rxnorm.py +++ b/tests/test_rxnorm.py @@ -1,9 +1,9 @@ """Test RxNorm data source.""" + import json import os from io import TextIOWrapper from pathlib import Path -from typing import Dict import pytest import requests_mock @@ -42,7 +42,7 @@ def rxnorm_file(fixture_dir): def test_get_latest( rxnorm: RxNormData, rxnorm_data_dir: Path, - latest_release_response: Dict, + latest_release_response: dict, rxnorm_file: TextIOWrapper, ): """Test RxNormData.get_latest()"""