From 5bde7dc919767a2724c2bd0292954c0fe9d590d3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:19:19 -0700 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#3003) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.6.0) - [github.com/astral-sh/ruff-pre-commit: v0.2.0 → v0.4.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.0...v0.4.9) - [github.com/tox-dev/tox-ini-fmt: 0.5.2 → 1.3.1](https://github.com/tox-dev/tox-ini-fmt/compare/0.5.2...1.3.1) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: C. Titus Brown --- .pre-commit-config.yaml | 14 +++---- src/sourmash/__init__.py | 1 + src/sourmash/command_compute.py | 1 + src/sourmash/command_sketch.py | 1 + src/sourmash/commands.py | 1 + src/sourmash/distance_utils.py | 1 + src/sourmash/fig.py | 1 + src/sourmash/index/sqlite_index.py | 1 + src/sourmash/lca/command_classify.py | 1 + src/sourmash/lca/command_compare_csv.py | 1 + src/sourmash/lca/command_index.py | 1 + src/sourmash/lca/command_rankinfo.py | 1 + src/sourmash/lca/command_summarize.py | 1 + src/sourmash/lca/lca_db.py | 9 ++--- src/sourmash/lca/lca_utils.py | 1 + src/sourmash/manifest.py | 1 + src/sourmash/minhash.py | 1 + src/sourmash/nodegraph.py | 4 +- src/sourmash/picklist.py | 1 + src/sourmash/save_load.py | 1 + src/sourmash/sbt.py | 16 ++------ src/sourmash/search.py | 1 + src/sourmash/sig/__main__.py | 5 +-- src/sourmash/sig/grep.py | 1 + src/sourmash/signature.py | 3 +- src/sourmash/sketchcomparison.py | 1 + src/sourmash/sourmash_args.py | 1 + src/sourmash/sqlite_utils.py | 1 + src/sourmash/tax/__main__.py | 1 + src/sourmash/tax/tax_utils.py | 25 ++++++------ src/sourmash/utils.py | 2 +- tests/sourmash_tst_utils.py | 1 + tests/test_cmd_signature.py | 1 + tests/test_cmd_signature_collect.py | 1 + tests/test_cmd_signature_fileinfo.py | 1 + tests/test_cmd_signature_grep.py | 1 + tests/test_distance_utils.py | 1 + tests/test_index.py | 1 + tests/test_lca.py | 1 + tests/test_lca_db_protocol.py | 1 + tests/test_lca_functions.py | 1 + tests/test_manifest.py | 1 + tests/test_nodegraph.py | 6 ++- tests/test_picklist.py | 1 + tests/test_prefetch.py | 1 + tests/test_sbt.py | 1 + tests/test_sourmash.py | 51 ++++++------------------- tests/test_sourmash_args.py | 1 + tests/test_sourmash_compute.py | 1 + tests/test_sourmash_sketch.py | 1 + tests/test_sqlite_index.py | 1 + tests/test_tax.py | 1 + utils/check-tree.py | 1 + 53 files changed, 93 insertions(+), 85 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50ab4e2c26..c55da1d1a3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-ast - id: check-builtin-literals @@ -10,16 +10,16 @@ repos: - id: check-toml - id: debug-statements - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.0 + rev: v0.4.9 hooks: - id: ruff-format - id: ruff args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"] - - repo: https://github.com/tox-dev/tox-ini-fmt - rev: "0.5.2" - hooks: - - id: tox-ini-fmt - args: ["-p", "fix_lint"] +# - repo: https://github.com/tox-dev/tox-ini-fmt +# rev: "1.3.1" +# hooks: +# - id: tox-ini-fmt +# args: ["-p", "fix_lint"] - repo: meta hooks: - id: check-hooks-apply diff --git a/src/sourmash/__init__.py b/src/sourmash/__init__.py index b6107d08c0..57b8f2679b 100644 --- a/src/sourmash/__init__.py +++ b/src/sourmash/__init__.py @@ -15,6 +15,7 @@ class MinHash - hash sketch class The sourmash code is available at github.com/sourmash-bio/sourmash/ under the BSD 3-Clause license. """ + from deprecation import deprecated from importlib.metadata import version diff --git a/src/sourmash/command_compute.py b/src/sourmash/command_compute.py index dbb3c42ad1..78edc8dcaa 100644 --- a/src/sourmash/command_compute.py +++ b/src/sourmash/command_compute.py @@ -1,6 +1,7 @@ """ Functions implementing the 'compute' command and related functions. """ + import os import os.path import sys diff --git a/src/sourmash/command_sketch.py b/src/sourmash/command_sketch.py index e98212f8c1..d962d2ec77 100644 --- a/src/sourmash/command_sketch.py +++ b/src/sourmash/command_sketch.py @@ -1,6 +1,7 @@ """ Functions implementing the 'sketch' subcommands and related functions. """ + import sys import os from collections import defaultdict, Counter diff --git a/src/sourmash/commands.py b/src/sourmash/commands.py index 0b25f34d5e..274e87d0fe 100644 --- a/src/sourmash/commands.py +++ b/src/sourmash/commands.py @@ -1,6 +1,7 @@ """ Functions implementing the main command-line subcommands. """ + import csv import os import os.path diff --git a/src/sourmash/distance_utils.py b/src/sourmash/distance_utils.py index 9106bd8812..ad267bd0fe 100644 --- a/src/sourmash/distance_utils.py +++ b/src/sourmash/distance_utils.py @@ -3,6 +3,7 @@ Equations from: https://github.com/KoslickiLab/mutation-rate-ci-calculator Reference: https://doi.org/10.1101/2022.01.11.475870 """ + from dataclasses import dataclass, field from scipy.optimize import brentq from scipy.stats import norm as scipy_norm diff --git a/src/sourmash/fig.py b/src/sourmash/fig.py index 9ca96f1aab..33a6fd4502 100644 --- a/src/sourmash/fig.py +++ b/src/sourmash/fig.py @@ -2,6 +2,7 @@ """ Make plots using the distance matrix+labels output by `sourmash compare`. """ + from .logging import error, notify try: diff --git a/src/sourmash/index/sqlite_index.py b/src/sourmash/index/sqlite_index.py index 458d40919d..829155d53c 100644 --- a/src/sourmash/index/sqlite_index.py +++ b/src/sourmash/index/sqlite_index.py @@ -73,6 +73,7 @@ should work fine for many simultaneous queries; just don't write :). """ + import time import os import sqlite3 diff --git a/src/sourmash/lca/command_classify.py b/src/sourmash/lca/command_classify.py index 4ea5ae69ec..48ee20db3a 100644 --- a/src/sourmash/lca/command_classify.py +++ b/src/sourmash/lca/command_classify.py @@ -2,6 +2,7 @@ """ Classify individual signature files down to deepest possible node. """ + import sys import csv diff --git a/src/sourmash/lca/command_compare_csv.py b/src/sourmash/lca/command_compare_csv.py index c8018256f0..5eb88624cf 100644 --- a/src/sourmash/lca/command_compare_csv.py +++ b/src/sourmash/lca/command_compare_csv.py @@ -2,6 +2,7 @@ """ Compare two taxonomy spreadsheets. """ + import sys from collections import defaultdict diff --git a/src/sourmash/lca/command_index.py b/src/sourmash/lca/command_index.py index f75a0ec8f2..df17debf7c 100644 --- a/src/sourmash/lca/command_index.py +++ b/src/sourmash/lca/command_index.py @@ -2,6 +2,7 @@ """ Build a lowest-common-ancestor database with given taxonomy and genome sigs. """ + import sys import csv import os diff --git a/src/sourmash/lca/command_rankinfo.py b/src/sourmash/lca/command_rankinfo.py index af0dbfa9d9..b409f656df 100644 --- a/src/sourmash/lca/command_rankinfo.py +++ b/src/sourmash/lca/command_rankinfo.py @@ -2,6 +2,7 @@ """ Summarize rank-specific information from LCAs in one or more databases. """ + import sys from collections import defaultdict diff --git a/src/sourmash/lca/command_summarize.py b/src/sourmash/lca/command_summarize.py index 02b57e60e1..81e7254e7f 100644 --- a/src/sourmash/lca/command_summarize.py +++ b/src/sourmash/lca/command_summarize.py @@ -2,6 +2,7 @@ """ Summarize the taxonomic content of the given signatures, combined. """ + import sys import csv from collections import defaultdict diff --git a/src/sourmash/lca/lca_db.py b/src/sourmash/lca/lca_db.py index 78855c71b8..5ee2e5e319 100644 --- a/src/sourmash/lca/lca_db.py +++ b/src/sourmash/lca/lca_db.py @@ -1,4 +1,5 @@ "LCA database class and utilities." + import os import json import gzip @@ -157,16 +158,12 @@ def insert(self, sig, ident=None, lineage=None): if minhash.ksize != self.ksize: raise ValueError( - "cannot insert signature with ksize {} into DB (ksize {})".format( - minhash.ksize, self.ksize - ) + f"cannot insert signature with ksize {minhash.ksize} into DB (ksize {self.ksize})" ) if minhash.moltype != self.moltype: raise ValueError( - "cannot insert signature with moltype {} into DB (moltype {})".format( - minhash.moltype, self.moltype - ) + f"cannot insert signature with moltype {minhash.moltype} into DB (moltype {self.moltype})" ) # downsample to specified scaled; this has the side effect of diff --git a/src/sourmash/lca/lca_utils.py b/src/sourmash/lca/lca_utils.py index 70b883bb7d..2b8fb2daa5 100644 --- a/src/sourmash/lca/lca_utils.py +++ b/src/sourmash/lca/lca_utils.py @@ -1,6 +1,7 @@ """ Utility functions for lowest-common-ancestor analysis tools. """ + from os.path import exists from collections import namedtuple, defaultdict, Counter diff --git a/src/sourmash/manifest.py b/src/sourmash/manifest.py index 2f00f5c382..f277d77f3f 100644 --- a/src/sourmash/manifest.py +++ b/src/sourmash/manifest.py @@ -1,6 +1,7 @@ """ Manifests for collections of signatures. """ + import csv import ast import gzip diff --git a/src/sourmash/minhash.py b/src/sourmash/minhash.py index ffa879b64d..90d8244e2d 100644 --- a/src/sourmash/minhash.py +++ b/src/sourmash/minhash.py @@ -4,6 +4,7 @@ class MinHash - core MinHash class. class FrozenMinHash - read-only MinHash class. """ + from .distance_utils import ( jaccard_to_distance, containment_to_distance, diff --git a/src/sourmash/nodegraph.py b/src/sourmash/nodegraph.py index 3204e11b7e..fe72b477a3 100644 --- a/src/sourmash/nodegraph.py +++ b/src/sourmash/nodegraph.py @@ -152,11 +152,11 @@ def calc_expected_collisions(graph, force=False, max_false_pos=0.2): print("** Do not use these results!!", file=sys.stderr) print("**", file=sys.stderr) print( - "** (estimated false positive rate of %.3f;" % fp_all, + f"** (estimated false positive rate of {fp_all:.3f};", file=sys.stderr, end=" ", ) - print("max recommended %.3f)" % max_false_pos, file=sys.stderr) + print(f"max recommended {max_false_pos:.3f})", file=sys.stderr) print("**", file=sys.stderr) if not force: diff --git a/src/sourmash/picklist.py b/src/sourmash/picklist.py index 8a5652eb1a..b646b0b9f0 100644 --- a/src/sourmash/picklist.py +++ b/src/sourmash/picklist.py @@ -9,6 +9,7 @@ and operate efficiently on manifests, so when used with e.g. zipfiles, only the selected sketches are loaded. """ + import csv import os from enum import Enum diff --git a/src/sourmash/save_load.py b/src/sourmash/save_load.py index 850d7f2b10..2b8c0d8aa9 100644 --- a/src/sourmash/save_load.py +++ b/src/sourmash/save_load.py @@ -24,6 +24,7 @@ CTB TODO: * consider replacing ValueError with IndexNotLoaded in the future. """ + import sys import os import gzip diff --git a/src/sourmash/sbt.py b/src/sourmash/sbt.py index ccb7fc3d78..4db7f5c135 100644 --- a/src/sourmash/sbt.py +++ b/src/sourmash/sbt.py @@ -3,7 +3,6 @@ An implementation of sequence bloom trees, Solomon & Kingsford, 2015. """ - from collections import namedtuple, Counter from collections.abc import Mapping @@ -103,7 +102,7 @@ def popitem(self): # we just need to select the maximum key/node id (key, _) = max(c for c in common if c[1] == count) except IndexError: - msg = "%s is empty" % self.__class__.__name__ + msg = f"{self.__class__.__name__} is empty" raise KeyError(msg) from None else: value = self.pop(key) @@ -1404,11 +1403,7 @@ def __init__(self, factory, name=None, path=None, storage=None): self.metadata = {} def __str__(self): - return "*Node:{name} [occupied: {nb}, fpr: {fpr:.2}]".format( - name=self.name, - nb=self.data.n_occupied(), - fpr=calc_expected_collisions(self.data, True, 1.1), - ) + return f"*Node:{self.name} [occupied: {self.data.n_occupied()}, fpr: {calc_expected_collisions(self.data, True, 1.1):.2}]" def save(self, path): buf = self.data.to_bytes(compression=1) @@ -1468,12 +1463,7 @@ def __init__(self, metadata, data=None, name=None, storage=None, path=None): self._path = path def __str__(self): - return "**Leaf:{name} [occupied: {nb}, fpr: {fpr:.2}] -> {metadata}".format( - name=self.name, - metadata=self.metadata, - nb=self.data.n_occupied(), - fpr=calc_expected_collisions(self.data, True, 1.1), - ) + return f"**Leaf:{self.name} [occupied: {self.data.n_occupied()}, fpr: {calc_expected_collisions(self.data, True, 1.1):.2}] -> {self.metadata}" def make_manifest_row(self, location): return None diff --git a/src/sourmash/search.py b/src/sourmash/search.py index 3ac9ab6a75..ec389e1b17 100644 --- a/src/sourmash/search.py +++ b/src/sourmash/search.py @@ -1,6 +1,7 @@ """ Code for searching collections of signatures. """ + import csv import numpy as np from enum import Enum diff --git a/src/sourmash/sig/__main__.py b/src/sourmash/sig/__main__.py index 2114d9dabb..13022e017e 100644 --- a/src/sourmash/sig/__main__.py +++ b/src/sourmash/sig/__main__.py @@ -1,6 +1,7 @@ """ Command-line entry point for 'python -m sourmash.sig' """ + __all__ = [ "cat", "split", @@ -81,9 +82,7 @@ def _check_abundance_compatibility(sig1, sig2): if sig1.minhash.track_abundance != sig2.minhash.track_abundance: raise ValueError( - "incompatible signatures: track_abundance is {} in first sig, {} in second".format( - sig1.minhash.track_abundance, sig2.minhash.track_abundance - ) + f"incompatible signatures: track_abundance is {sig1.minhash.track_abundance} in first sig, {sig2.minhash.track_abundance} in second" ) diff --git a/src/sourmash/sig/grep.py b/src/sourmash/sig/grep.py index cfdc857779..2da803edb2 100644 --- a/src/sourmash/sig/grep.py +++ b/src/sourmash/sig/grep.py @@ -1,6 +1,7 @@ """ Command-line entry point for 'python -m sourmash.sig grep' """ + import sys import re diff --git a/src/sourmash/signature.py b/src/sourmash/signature.py index 6f0a9d7b83..dbd3248f77 100644 --- a/src/sourmash/signature.py +++ b/src/sourmash/signature.py @@ -2,6 +2,7 @@ """ Save and load MinHash sketches in a JSON format, along with some metadata. """ + import sys import os import weakref @@ -367,7 +368,7 @@ def _detect_input_type(data): except TypeError: if data.find(b"sourmash_signature") > 0: return SigInput.BUFFER - elif data.startswith(b"\x1F\x8B"): # gzip compressed + elif data.startswith(b"\x1f\x8b"): # gzip compressed return SigInput.BUFFER try: diff --git a/src/sourmash/sketchcomparison.py b/src/sourmash/sketchcomparison.py index e80013edaa..188e64cf79 100644 --- a/src/sourmash/sketchcomparison.py +++ b/src/sourmash/sketchcomparison.py @@ -1,6 +1,7 @@ """ Sketch Comparison Classes """ + import numpy as np from dataclasses import dataclass diff --git a/src/sourmash/sourmash_args.py b/src/sourmash/sourmash_args.py index c4483cfe6c..9f2068160a 100644 --- a/src/sourmash/sourmash_args.py +++ b/src/sourmash/sourmash_args.py @@ -36,6 +36,7 @@ misc support: * FileInputCSV - context manager for reading CSVs """ + import sys import os import csv diff --git a/src/sourmash/sqlite_utils.py b/src/sourmash/sqlite_utils.py index 8efb754a23..0e701b9e44 100644 --- a/src/sourmash/sqlite_utils.py +++ b/src/sourmash/sqlite_utils.py @@ -1,6 +1,7 @@ """ Common utility functions for handling sqlite3 databases. """ + import os import sqlite3 from .logging import debug_literal diff --git a/src/sourmash/tax/__main__.py b/src/sourmash/tax/__main__.py index 1a5d22940a..f0c8b4f2df 100644 --- a/src/sourmash/tax/__main__.py +++ b/src/sourmash/tax/__main__.py @@ -1,6 +1,7 @@ """ Command-line entry point for 'python -m sourmash.tax' """ + import sys import csv import os diff --git a/src/sourmash/tax/tax_utils.py b/src/sourmash/tax/tax_utils.py index a2fbeb3f30..5af08f91fc 100644 --- a/src/sourmash/tax/tax_utils.py +++ b/src/sourmash/tax/tax_utils.py @@ -1,6 +1,7 @@ """ Utility functions for taxonomy analysis tools. """ + import os import csv from collections import abc, defaultdict @@ -1001,9 +1002,9 @@ def aggregate_by_lineage_at_rank(query_gather_results, rank, *, by_query=False): for res in queryResult.summarized_lineage_results[rank]: lineage = res.lineage.display_lineage(null_as_unclassified=True) if by_query: - lineage_summary[lineage][ - query_name - ] = res.fraction # v5?: res.f_weighted_at_rank + lineage_summary[lineage][query_name] = ( + res.fraction + ) # v5?: res.f_weighted_at_rank else: lineage_summary[lineage] += res.fraction @@ -2346,15 +2347,15 @@ def summarize_up_ranks(self, single_rank=None, force_resummarize=False): rank in lininfo.filled_ranks ): # only store if this rank is filled. lin_at_rank = lininfo.pop_to_rank(rank) - self.sum_uniq_weighted[rank][ - lin_at_rank - ] += taxres.f_unique_weighted - self.sum_uniq_to_query[rank][ - lin_at_rank - ] += taxres.f_unique_to_query - self.sum_uniq_bp[rank][ - lin_at_rank - ] += taxres.unique_intersect_bp + self.sum_uniq_weighted[rank][lin_at_rank] += ( + taxres.f_unique_weighted + ) + self.sum_uniq_to_query[rank][lin_at_rank] += ( + taxres.f_unique_to_query + ) + self.sum_uniq_bp[rank][lin_at_rank] += ( + taxres.unique_intersect_bp + ) # reset ranks levels to the ones that were actually summarized + that we can access for summarized result self.summarized_ranks = [ x for x in self.summarized_ranks if x in self.sum_uniq_bp.keys() diff --git a/src/sourmash/utils.py b/src/sourmash/utils.py index 1910504e05..755ce9ffc3 100644 --- a/src/sourmash/utils.py +++ b/src/sourmash/utils.py @@ -12,7 +12,7 @@ class RustObject: _shared = False def __init__(self): - raise TypeError("Cannot instanciate %r objects" % self.__class__.__name__) + raise TypeError(f"Cannot instanciate {self.__class__.__name__!r} objects") @classmethod def _from_objptr(cls, ptr, shared=False): diff --git a/tests/sourmash_tst_utils.py b/tests/sourmash_tst_utils.py index a2a35cb2e6..abf56ea524 100644 --- a/tests/sourmash_tst_utils.py +++ b/tests/sourmash_tst_utils.py @@ -1,4 +1,5 @@ "Various utilities used by sourmash tests." + import sys import os import tempfile diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index b81ce1f34a..c75bc708d0 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -1,6 +1,7 @@ """ Tests for the 'sourmash signature' command line. """ + import csv import shutil import os diff --git a/tests/test_cmd_signature_collect.py b/tests/test_cmd_signature_collect.py index 917286e881..a1de970ea9 100644 --- a/tests/test_cmd_signature_collect.py +++ b/tests/test_cmd_signature_collect.py @@ -1,6 +1,7 @@ """ Tests for 'sourmash sig collect' """ + import pytest import shutil import os.path diff --git a/tests/test_cmd_signature_fileinfo.py b/tests/test_cmd_signature_fileinfo.py index 25e29a5b4f..bfafdb7646 100644 --- a/tests/test_cmd_signature_fileinfo.py +++ b/tests/test_cmd_signature_fileinfo.py @@ -1,6 +1,7 @@ """ Tests for the 'sourmash signature fileinfo' command line. """ + import shutil import os import glob diff --git a/tests/test_cmd_signature_grep.py b/tests/test_cmd_signature_grep.py index 4e5a26f289..5af8a2c56c 100644 --- a/tests/test_cmd_signature_grep.py +++ b/tests/test_cmd_signature_grep.py @@ -1,6 +1,7 @@ """ Tests for the 'sourmash signature grep' command line. """ + import shutil import os import csv diff --git a/tests/test_distance_utils.py b/tests/test_distance_utils.py index 25e69186f3..e772da3bfd 100644 --- a/tests/test_distance_utils.py +++ b/tests/test_distance_utils.py @@ -1,6 +1,7 @@ """ Tests for distance utils. """ + import pytest import numpy as np from sourmash.distance_utils import ( diff --git a/tests/test_index.py b/tests/test_index.py index 2c1799d113..70853a0b4e 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -1,6 +1,7 @@ """ Tests for Index classes and subclasses. """ + import pytest import glob import os diff --git a/tests/test_lca.py b/tests/test_lca.py index f844422ef3..6b2d308001 100644 --- a/tests/test_lca.py +++ b/tests/test_lca.py @@ -1,6 +1,7 @@ """ Tests for the 'sourmash lca' command line and high level API. """ + import os import shutil import csv diff --git a/tests/test_lca_db_protocol.py b/tests/test_lca_db_protocol.py index eb2f76fe07..6724c3fd27 100644 --- a/tests/test_lca_db_protocol.py +++ b/tests/test_lca_db_protocol.py @@ -2,6 +2,7 @@ Test the behavior of LCA databases. New LCA database classes should support all of this functionality. """ + import pytest import sourmash_tst_utils as utils diff --git a/tests/test_lca_functions.py b/tests/test_lca_functions.py index 9add0df47f..c10ce26dff 100644 --- a/tests/test_lca_functions.py +++ b/tests/test_lca_functions.py @@ -1,6 +1,7 @@ """ Tests for functions in lca submodule. """ + import pytest from sourmash.lca import lca_utils diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 138ae0f829..2f0f249c39 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -1,6 +1,7 @@ """ Tests for manifest code in databases, etc. """ + import pytest from io import StringIO diff --git a/tests/test_nodegraph.py b/tests/test_nodegraph.py index bc9e02754b..0f3faa3c61 100644 --- a/tests/test_nodegraph.py +++ b/tests/test_nodegraph.py @@ -62,7 +62,11 @@ def test_nodegraph_same_file(): khmer_ng = load_nodegraph(ng_file) - with NamedTemporaryFile() as f1, NamedTemporaryFile() as f2, NamedTemporaryFile() as f3: + with ( + NamedTemporaryFile() as f1, + NamedTemporaryFile() as f2, + NamedTemporaryFile() as f3, + ): sourmash_ng.save(f1.name) khmer_sm_ng.save(f2.name) khmer_ng.save(f3.name) diff --git a/tests/test_picklist.py b/tests/test_picklist.py index 682d6fb8af..d6592a57b0 100644 --- a/tests/test_picklist.py +++ b/tests/test_picklist.py @@ -1,6 +1,7 @@ """ Tests for the picklist API. """ + import pytest import sourmash diff --git a/tests/test_prefetch.py b/tests/test_prefetch.py index fc73a2d724..83dbe66d5e 100644 --- a/tests/test_prefetch.py +++ b/tests/test_prefetch.py @@ -1,6 +1,7 @@ """ Tests for `sourmash prefetch` command-line and API functionality. """ + import os import csv import gzip diff --git a/tests/test_sbt.py b/tests/test_sbt.py index cfc71d43dd..6f4b2da767 100644 --- a/tests/test_sbt.py +++ b/tests/test_sbt.py @@ -1,4 +1,5 @@ "Test SBT code." + import json import shutil import os diff --git a/tests/test_sourmash.py b/tests/test_sourmash.py index dfb4b1eda8..e7f1d46b67 100644 --- a/tests/test_sourmash.py +++ b/tests/test_sourmash.py @@ -1,6 +1,7 @@ """ Tests for the 'sourmash' command line. """ + import os import gzip import shutil @@ -4851,11 +4852,7 @@ def test_multigather_check_scaled_bounds_negative(runtmp): cmd.extend(["-k", "21"]) c.run_sourmash(*cmd) - cmd = ( - "multigather --query {} --db gcf_all -k 21 --scaled -5 --threshold-bp=0".format( - query_sig - ) - ) + cmd = f"multigather --query {query_sig} --db gcf_all -k 21 --scaled -5 --threshold-bp=0" cmd = cmd.split(" ") with pytest.raises(SourmashCommandFailed) as exc: c.run_sourmash(*cmd) @@ -4875,11 +4872,7 @@ def test_multigather_check_scaled_bounds_less_than_minimum(runtmp): cmd.extend(["-k", "21"]) c.run_sourmash(*cmd) - cmd = ( - "multigather --query {} --db gcf_all -k 21 --scaled 50 --threshold-bp=0".format( - query_sig - ) - ) + cmd = f"multigather --query {query_sig} --db gcf_all -k 21 --scaled 50 --threshold-bp=0" cmd = cmd.split(" ") # Note: this is the value error that is emitted, but we want the Warning from below to be generated instead. (ValueError: new scaled 50.0 is lower than current sample scaled 10000) with pytest.raises(SourmashCommandFailed) as exc: @@ -4902,9 +4895,7 @@ def test_multigather_check_scaled_bounds_more_than_maximum(runtmp): cmd.extend(["-k", "21"]) c.run_sourmash(*cmd) - cmd = "multigather --query {} --db gcf_all -k 21 --scaled 1e9 --threshold-bp=0".format( - query_sig - ) + cmd = f"multigather --query {query_sig} --db gcf_all -k 21 --scaled 1e9 --threshold-bp=0" cmd = cmd.split(" ") c.run_sourmash(*cmd) @@ -4935,9 +4926,7 @@ def test_multigather_metagenome_query_from_file(runtmp): with open(query_list, "w") as fp: print(query_sig, file=fp) - cmd = "multigather --query-from-file {} --db gcf_all -k 21 --threshold-bp=0".format( - query_list - ) + cmd = f"multigather --query-from-file {query_list} --db gcf_all -k 21 --threshold-bp=0" cmd = cmd.split(" ") c.run_sourmash(*cmd) @@ -5113,9 +5102,7 @@ def test_multigather_metagenome_query_on_lca_db(runtmp): testdata_sig2 = utils.get_test_data("63.fa.sig") lca_db = utils.get_test_data("lca/47+63.lca.json") - cmd = "multigather --query {} {} --db {} -k 31 --threshold-bp=0".format( - testdata_sig1, testdata_sig2, lca_db - ) + cmd = f"multigather --query {testdata_sig1} {testdata_sig2} --db {lca_db} -k 31 --threshold-bp=0" cmd = cmd.split(" ") c.run_sourmash(*cmd) @@ -5157,9 +5144,7 @@ def test_multigather_metagenome_query_with_sbt_addl_query(runtmp): assert os.path.exists(c.output("gcf_all.sbt.zip")) - cmd = "multigather --query {} gcf_all.sbt.zip --db gcf_all.sbt.zip -k 21 --threshold-bp=0 --force-allow-overwrite-output".format( - another_query - ) + cmd = f"multigather --query {another_query} gcf_all.sbt.zip --db gcf_all.sbt.zip -k 21 --threshold-bp=0 --force-allow-overwrite-output" cmd = cmd.split(" ") c.run_sourmash(*cmd) @@ -5224,11 +5209,7 @@ def test_multigather_metagenome_query_with_sbt_addl_query_fail_overwrite(runtmp) assert os.path.exists(c.output("gcf_all.sbt.zip")) - cmd = ( - "multigather --query {} {} --db gcf_all.sbt.zip -k 21 --threshold-bp=0".format( - another_query, another_query - ) - ) + cmd = f"multigather --query {another_query} {another_query} --db gcf_all.sbt.zip -k 21 --threshold-bp=0" cmd = cmd.split(" ") with pytest.raises(SourmashCommandFailed): @@ -5264,9 +5245,7 @@ def test_multigather_metagenome_query_with_sbt_addl_query_fail_overwrite_force(r assert os.path.exists(c.output("gcf_all.sbt.zip")) - cmd = "multigather --query {} {} --db gcf_all.sbt.zip -k 21 --threshold-bp=0 --force-allow-overwrite-output".format( - another_query, another_query - ) + cmd = f"multigather --query {another_query} {another_query} --db gcf_all.sbt.zip -k 21 --threshold-bp=0 --force-allow-overwrite-output" cmd = cmd.split(" ") c.run_sourmash(*cmd) @@ -5307,9 +5286,7 @@ def test_multigather_metagenome_sbt_query_from_file_with_addl_query(runtmp): with open(query_list, "w") as fp: print("gcf_all.sbt.zip", file=fp) - cmd = "multigather --query {} --query-from-file {} --db gcf_all.sbt.zip {} -k 21 --threshold-bp=0".format( - another_query, query_list, another_query - ) + cmd = f"multigather --query {another_query} --query-from-file {query_list} --db gcf_all.sbt.zip {another_query} -k 21 --threshold-bp=0" cmd = cmd.split(" ") c.run_sourmash(*cmd) @@ -5403,9 +5380,7 @@ def test_multigather_metagenome_lca_query_from_file(runtmp): with open(query_list, "w") as fp: print(lca_db, file=fp) - cmd = "multigather --query-from-file {} --db 47+63.sbt.zip -k 31 --threshold-bp=0".format( - query_list - ) + cmd = f"multigather --query-from-file {query_list} --db 47+63.sbt.zip -k 31 --threshold-bp=0" cmd = cmd.split(" ") c.run_sourmash(*cmd) @@ -5445,9 +5420,7 @@ def test_multigather_metagenome_query_from_file_with_addl_query(runtmp): "gather/GCF_000195995.1_ASM19599v1_genomic.fna.gz.sig" ) - cmd = "multigather --query-from-file {} --query {} --db gcf_all -k 21 --threshold-bp=0".format( - query_list, another_query - ) + cmd = f"multigather --query-from-file {query_list} --query {another_query} --db gcf_all -k 21 --threshold-bp=0" cmd = cmd.split(" ") c.run_sourmash(*cmd) diff --git a/tests/test_sourmash_args.py b/tests/test_sourmash_args.py index 916cabb1e3..3d90461d8d 100644 --- a/tests/test_sourmash_args.py +++ b/tests/test_sourmash_args.py @@ -1,6 +1,7 @@ """ Tests for functions in sourmash_args module. """ + import sys import os import pytest diff --git a/tests/test_sourmash_compute.py b/tests/test_sourmash_compute.py index ddab496cbb..35f5635237 100644 --- a/tests/test_sourmash_compute.py +++ b/tests/test_sourmash_compute.py @@ -1,6 +1,7 @@ """ Tests for sourmash compute command-line functionality. """ + import os import gzip import shutil diff --git a/tests/test_sourmash_sketch.py b/tests/test_sourmash_sketch.py index 6537383b77..88332b1945 100644 --- a/tests/test_sourmash_sketch.py +++ b/tests/test_sourmash_sketch.py @@ -1,6 +1,7 @@ """ Tests for sourmash sketch command-line functionality. """ + import os import gzip import shutil diff --git a/tests/test_sqlite_index.py b/tests/test_sqlite_index.py index 816719e602..0a27efddf6 100644 --- a/tests/test_sqlite_index.py +++ b/tests/test_sqlite_index.py @@ -1,4 +1,5 @@ "Tests for SqliteIndex, SqliteCollectionManifest, and LCA_SqliteDatabase" + import os import pytest import shutil diff --git a/tests/test_tax.py b/tests/test_tax.py index fc68b6448d..389a536619 100644 --- a/tests/test_tax.py +++ b/tests/test_tax.py @@ -1,6 +1,7 @@ """ Tests for the 'sourmash tax' command line and high level API. """ + import os import csv import pytest diff --git a/utils/check-tree.py b/utils/check-tree.py index 639e376e3b..142ff86bfa 100644 --- a/utils/check-tree.py +++ b/utils/check-tree.py @@ -3,6 +3,7 @@ Check SBT search by taking every leaf node in a tree and checking to make sure we can find it. """ + import argparse import sourmash from sourmash.sbtmh import search_minhashes