From 2ed86fc2887a91c4660ffbad9867f72ee6db5da3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2026 16:32:08 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.6 → v0.16.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.6...v0.16.3) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61fbd30..d0e13a9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.15.6 + rev: v0.16.3 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 0716e0e38d2011703d4f8e01f925076395de40b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2026 16:33:27 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- setup.py | 2 +- src/biostrings/dnastring.py | 8 ++++---- src/biostrings/dnastringset.py | 24 ++++++++++++------------ tests/test_dnastring.py | 1 - tests/test_dnastringset.py | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/setup.py b/setup.py index b115474..bb42d70 100644 --- a/setup.py +++ b/setup.py @@ -75,7 +75,7 @@ def build_cmake(self, ext): ext_modules=[CMakeExtension("biostrings")], cmdclass={"build_ext": build_ext}, ) - except: # noqa + except: print( "\n\nAn error occurred while building the project, " "please ensure you have the most updated version of setuptools, " diff --git a/src/biostrings/dnastring.py b/src/biostrings/dnastring.py index c9a86a8..d695612 100644 --- a/src/biostrings/dnastring.py +++ b/src/biostrings/dnastring.py @@ -2,7 +2,7 @@ import re from copy import deepcopy -from typing import Any, Dict, Optional, Union +from typing import Any import biocutils as ut @@ -34,8 +34,8 @@ class DNAString(ut.BiocObject): def __init__( self, - sequence: Union[str, bytes], - metadata: Optional[Union[Dict[str, Any], ut.NamedList]] = None, + sequence: str | bytes, + metadata: dict[str, Any] | ut.NamedList | None = None, _validate: bool = True, ): """Create a DNAString. @@ -145,7 +145,7 @@ def __eq__(self, other) -> bool: #### Getitem/setitem #### ######################### - def __getitem__(self, key: Union[int, slice]) -> DNAString: + def __getitem__(self, key: int | slice) -> DNAString: """Extract a subsequence (slicing). Args: diff --git a/src/biostrings/dnastringset.py b/src/biostrings/dnastringset.py index 2c666e6..c42601e 100644 --- a/src/biostrings/dnastringset.py +++ b/src/biostrings/dnastringset.py @@ -1,7 +1,7 @@ from __future__ import annotations from copy import deepcopy -from typing import Any, Dict, List, Optional, Union +from typing import Any from warnings import warn import biocutils as ut @@ -36,11 +36,11 @@ class DNAStringSet(ut.BiocObject): def __init__( self, - sequences: Optional[List[str]] = None, - names: Optional[Union[List[str], ut.Names]] = None, - _pool: Optional[bytes] = None, - _ranges: Optional[IRanges] = None, - metadata: Optional[Union[Dict[str, Any], ut.NamedList]] = None, + sequences: list[str] | None = None, + names: list[str] | ut.Names | None = None, + _pool: bytes | None = None, + _ranges: IRanges | None = None, + metadata: dict[str, Any] | ut.NamedList | None = None, _validate: bool = True, ): """Create a DNAStringSet. @@ -141,7 +141,7 @@ def __deepcopy__(self, memo) -> DNAStringSet: #### Getter/setters #### ######################## - def get_names(self) -> Optional[ut.Names]: + def get_names(self) -> ut.Names | None: """Get range names. Returns: @@ -150,7 +150,7 @@ def get_names(self) -> Optional[ut.Names]: """ return self._ranges.get_names() - def set_names(self, names: Optional[List[str]], in_place: bool = False) -> DNAStringSet: + def set_names(self, names: list[str] | None, in_place: bool = False) -> DNAStringSet: """ Args: names: @@ -169,12 +169,12 @@ def set_names(self, names: Optional[List[str]], in_place: bool = False) -> DNASt return output @property - def names(self) -> Optional[ut.Names]: + def names(self) -> ut.Names | None: """Return the names of the sequences.""" return self._ranges.get_names() @names.setter - def names(self, new_names: List[str]): + def names(self, new_names: list[str]): """Set the names of the sequences.""" warn( "Setting property 'names' is an in-place operation, use 'set_names' instead", @@ -251,7 +251,7 @@ def width(self) -> np.ndarray: """Alias to :py:meth:`~.get_width`.""" return self.get_width() - def __getitem__(self, key: Union[int, slice, List[int], np.ndarray]) -> Union[DNAString, DNAStringSet]: + def __getitem__(self, key: int | slice | list[int] | np.ndarray) -> DNAString | DNAStringSet: """Extract one or more sequences. Args: @@ -278,7 +278,7 @@ def __getitem__(self, key: Union[int, slice, List[int], np.ndarray]) -> Union[DN else: raise TypeError(f"Index must be int, slice, or list, not {type(key)}") - def to_list(self) -> List[str]: + def to_list(self) -> list[str]: """Convert the set to a list of Python strings.""" output = [] for i in range(len(self._ranges)): diff --git a/tests/test_dnastring.py b/tests/test_dnastring.py index ae1449a..1aa180a 100644 --- a/tests/test_dnastring.py +++ b/tests/test_dnastring.py @@ -84,7 +84,6 @@ def test_reverse_complement_simple(): def test_reverse_complement_iupac(): - # dna = DNAString("ACGTRYSWKMBDHVN-") rc = dna.reverse_complement() # From our complement table diff --git a/tests/test_dnastringset.py b/tests/test_dnastringset.py index 071877d..f3f7b87 100644 --- a/tests/test_dnastringset.py +++ b/tests/test_dnastringset.py @@ -12,7 +12,7 @@ def sample_seqs(): "ACGT", "GATTACA", "", - "TTGAAAA-CTC-N", # + "TTGAAAA-CTC-N", "ACGTACGT", ], "names": ["seq1", "seq2", "empty", "iupac", "seq5"],