[med-svn] [Git][med-team/python-dnaio][master] 10 commits: New upstream version
Lance Lin (@linqigang)
gitlab at salsa.debian.org
Fri Nov 13 14:58:30 GMT 2026
Lance Lin pushed to branch master at Debian Med / python-dnaio
Commits:
99080678 by Lance Lin at 2026-11-13T20:41:38+07:00
New upstream version
- - - - -
99386197 by Lance Lin at 2026-11-13T20:42:07+07:00
New upstream version 1.2.5
- - - - -
61827d00 by Lance Lin at 2026-11-13T20:42:08+07:00
Update upstream source from tag 'upstream/1.2.5'
Update to upstream version '1.2.5'
with Debian dir 90dde910e9cb5dc028e2b1048595c7050d4e058d
- - - - -
7dedcce8 by Lance Lin at 2026-11-13T20:42:08+07:00
Standards-Version: 4.7.4 (routine-update)
- - - - -
22434133 by Lance Lin at 2026-11-13T20:42:17+07:00
Changes made by cme
- - - - -
96f9d35b by Lance Lin at 2026-11-13T20:42:37+07:00
debputy lint --auto-fix (routine-update)
- - - - -
c764e08f by Lance Lin at 2026-11-13T21:47:19+07:00
d/source/lintian-overrides: Remove override, not needed.
- - - - -
3aba0ae4 by Lance Lin at 2026-11-13T21:48:49+07:00
d/control: Remove redundant Priority optional field.
- - - - -
f0f53fbb by Lance Lin at 2026-11-13T21:50:30+07:00
d/tests/control: Replace deprecated skip-not-installable with supported Architecture list.
- - - - -
47bdec90 by Lance Lin at 2026-11-13T21:51:47+07:00
d/changelog: Add team upload
- - - - -
26 changed files:
- + .github/dependabot.yml
- .github/workflows/ci.yml
- CHANGES.rst
- debian/changelog
- debian/control
- − debian/source/lintian-overrides
- debian/tests/control
- debian/watch
- pyproject.toml
- src/dnaio/__init__.py
- src/dnaio/_core.pyi
- src/dnaio/_util.py
- src/dnaio/chunks.py
- src/dnaio/exceptions.py
- src/dnaio/interfaces.py
- src/dnaio/multipleend.py
- src/dnaio/pairedend.py
- src/dnaio/readers.py
- src/dnaio/singleend.py
- src/dnaio/writers.py
- tests/test_chunks.py
- tests/test_internal.py
- tests/test_open.py
- tests/test_records.py
- − tox.ini
- + tox.toml
Changes:
=====================================
.github/dependabot.yml
=====================================
@@ -0,0 +1,10 @@
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ groups:
+ github-actions:
+ patterns:
+ - "*"
+ schedule:
+ interval: "weekly"
=====================================
.github/workflows/ci.yml
=====================================
@@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: ["3.10"]
- toxenv: [flake8, black, mypy, docs]
+ python-version: ["3.15"]
+ toxenv: [ruff, black, mypy, docs]
steps:
- - uses: actions/checkout at v4
+ - uses: actions/checkout at v7
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python at v5
+ uses: actions/setup-python at v7
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
@@ -31,12 +31,12 @@ jobs:
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout at v4
+ - uses: actions/checkout at v7
with:
fetch-depth: 0 # required for setuptools_scm
- name: Build sdist and temporary wheel
run: pipx run build
- - uses: actions/upload-artifact at v4
+ - uses: actions/upload-artifact at v7
with:
name: sdist
path: dist/*.tar.gz
@@ -50,22 +50,22 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
- python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
+ python-version: ["3.11", "3.12", "3.13", "3.14", "3.14t", "3.15", "3.15t"]
include:
- os: macos-latest
- python-version: "3.10"
+ python-version: "3.15"
steps:
- - uses: actions/checkout at v4
+ - uses: actions/checkout at v7
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python at v5
+ uses: actions/setup-python at v7
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: python -m pip install tox
- name: Test
- run: tox -e py
+ run: tox -e py$(echo ${{ matrix.python-version }} | tr -d .)
- name: Upload coverage report
- uses: codecov/codecov-action at v4
+ uses: codecov/codecov-action at v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
@@ -78,14 +78,14 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout at v4
+ - uses: actions/checkout at v7
with:
fetch-depth: 0 # required for setuptools_scm
- name: Build wheels
- uses: pypa/cibuildwheel at v3.2.1
+ uses: pypa/cibuildwheel at v4.3.5
env:
CIBW_BUILD: "cp*-manylinux_x86_64 cp3*-win_amd64 cp3*-macosx_x86_64 cp3*-macosx_arm64"
- - uses: actions/upload-artifact at v4
+ - uses: actions/upload-artifact at v7
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
@@ -95,11 +95,11 @@ jobs:
needs: [build, wheels]
runs-on: ubuntu-latest
steps:
- - uses: actions/download-artifact at v4
+ - uses: actions/download-artifact at v8
with:
name: sdist
path: dist/
- - uses: actions/download-artifact at v4
+ - uses: actions/download-artifact at v8
with:
pattern: wheels-*
path: dist/
=====================================
CHANGES.rst
=====================================
@@ -2,6 +2,12 @@
Changelog
=========
+v1.2.5 (2026-11-05)
+-------------------
+
+* Started supporting Python 3.15
+* Dropped support for Python 3.10
+
v1.2.4 (2025-10-12)
-------------------
=====================================
debian/changelog
=====================================
@@ -1,3 +1,16 @@
+python-dnaio (1.2.5-1) UNRELEASED; urgency=medium
+
+ * Team upload.
+ * New upstream version
+ * Standards-Version: 4.7.4 (routine-update)
+ * debputy lint --auto-fix (routine-update)
+ * d/source/lintian-overrides: Remove override, not needed.
+ * d/control: Remove redundant Priority optional field.
+ * d/tests/control: Replace deprecated skip-not-installable with
+ supported Architecture list.
+
+ -- Lance Lin <lq27267 at gmail.com> Fri, 13 Nov 2026 20:41:38 +0700
+
python-dnaio (1.2.4-1) unstable; urgency=medium
* New upstream version 1.2.4
=====================================
debian/control
=====================================
@@ -4,7 +4,7 @@ Uploaders: Liubov Chuprikova <chuprikovalv at gmail.com>,
Étienne Mollier <emollier at debian.org>
Section: python
Testsuite: autopkgtest-pkg-pybuild
-Build-Depends: debhelper-compat (= 13),
+Build-Depends: debhelper-compat (= 14),
architecture-is-little-endian,
dh-sequence-python3,
python3-all-dev,
@@ -14,7 +14,7 @@ Build-Depends: debhelper-compat (= 13),
python3-pytest <!nocheck>,
python3-xopen <!nocheck>,
cython3
-Standards-Version: 4.7.2
+Standards-Version: 4.7.4
Vcs-Browser: https://salsa.debian.org/med-team/python-dnaio
Vcs-Git: https://salsa.debian.org/med-team/python-dnaio.git
Homepage: https://github.com/marcelm/dnaio
=====================================
debian/source/lintian-overrides deleted
=====================================
@@ -1,5 +0,0 @@
-# See the discussion on d-devel for the rationale[1], this override is
-# probably going to be temporary.
-#
-# [1]: https://lists.debian.org/debian-devel/2024/12/msg00328.html
-recommended-field (in section for source) Priority [debian/control:*]
=====================================
debian/tests/control
=====================================
@@ -1,3 +1,4 @@
Tests: run-unit-test
Depends: @, unicycler-data
-Restrictions: allow-stderr, skip-not-installable
+Architecture: amd64, arm64, armel, armhf, i386, loong64, ppc64el, riscv64
+Restrictions: allow-stderr
=====================================
debian/watch
=====================================
@@ -3,5 +3,5 @@ Version: 5
Template: Github
Owner: marcelm
Project: dnaio
-Uversionmangle: s/rc/~rc/
-Dversionmangle: auto
+Uversion-Mangle: s/rc/~rc/
+Dversion-Mangle: auto
=====================================
pyproject.toml
=====================================
@@ -88,3 +88,15 @@ source = [
"src/",
"*/site-packages/",
]
+
+[tool.ruff.lint]
+ignore = [
+ "C408", # Unnecessary `dict()` call (rewrite as a literal)
+ "I001", # Import block is un-sorted or un-formatted
+ "PYI001", # Name of private `TypeVar` must start with `_`
+ "PYI057", # Do not use `typing.ByteString`, which has unclear semantics and is deprecated
+ "PYI063", # Use PEP 570 syntax for positional-only parameters
+ "RUF010", # Use explicit conversion flag
+ "RUF022", # `__all__` is not sorted
+ "SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
+]
=====================================
src/dnaio/__init__.py
=====================================
@@ -33,7 +33,7 @@ __all__ = [
import functools
from os import PathLike
-from typing import Optional, Union, BinaryIO, Literal, overload
+from typing import BinaryIO, Literal, overload
from xopen import xopen
@@ -74,26 +74,24 @@ from .interfaces import (
from .chunks import read_chunks, read_paired_chunks
from ._version import version as __version__
-
# Backwards compatibility alias
Sequence = SequenceRecord
-_FileOrPath = Union[str, PathLike, BinaryIO]
+_FileOrPath = str | PathLike | BinaryIO
@overload
def open(
_file: _FileOrPath,
*,
- fileformat: Optional[str] = ...,
+ fileformat: str | None = ...,
interleaved: Literal[False] = ...,
mode: Literal["r"] = ...,
- qualities: Optional[bool] = ...,
+ qualities: bool | None = ...,
opener=...,
compression_level: int = ...,
open_threads: int = ...,
-) -> SingleEndReader:
- ...
+) -> SingleEndReader: ...
@overload
@@ -101,15 +99,14 @@ def open(
_file1: _FileOrPath,
_file2: _FileOrPath,
*,
- fileformat: Optional[str] = ...,
+ fileformat: str | None = ...,
interleaved: Literal[False] = ...,
mode: Literal["r"] = ...,
- qualities: Optional[bool] = ...,
+ qualities: bool | None = ...,
opener=...,
compression_level: int = ...,
open_threads: int = ...,
-) -> PairedEndReader:
- ...
+) -> PairedEndReader: ...
@overload
@@ -117,14 +114,13 @@ def open(
_file: _FileOrPath,
*,
interleaved: Literal[True],
- fileformat: Optional[str] = ...,
+ fileformat: str | None = ...,
mode: Literal["r"] = ...,
- qualities: Optional[bool] = ...,
+ qualities: bool | None = ...,
opener=...,
compression_level: int = ...,
open_threads: int = ...,
-) -> PairedEndReader:
- ...
+) -> PairedEndReader: ...
@overload
@@ -133,14 +129,13 @@ def open(
_file2: _FileOrPath,
_file3: _FileOrPath,
*files: _FileOrPath,
- fileformat: Optional[str] = ...,
+ fileformat: str | None = ...,
mode: Literal["r"] = ...,
- qualities: Optional[bool] = ...,
+ qualities: bool | None = ...,
opener=...,
compression_level: int = ...,
open_threads: int = ...,
-) -> MultipleFileReader:
- ...
+) -> MultipleFileReader: ...
@overload
@@ -148,14 +143,13 @@ def open(
_file: _FileOrPath,
*,
mode: Literal["w", "a"],
- fileformat: Optional[str] = ...,
+ fileformat: str | None = ...,
interleaved: Literal[False] = ...,
- qualities: Optional[bool] = ...,
+ qualities: bool | None = ...,
opener=...,
compression_level: int = ...,
open_threads: int = ...,
-) -> SingleEndWriter:
- ...
+) -> SingleEndWriter: ...
@overload
@@ -164,14 +158,13 @@ def open(
_file2: _FileOrPath,
*,
mode: Literal["w", "a"],
- fileformat: Optional[str] = ...,
+ fileformat: str | None = ...,
interleaved: Literal[False] = ...,
- qualities: Optional[bool] = ...,
+ qualities: bool | None = ...,
opener=...,
compression_level: int = ...,
open_threads: int = ...,
-) -> PairedEndWriter:
- ...
+) -> PairedEndWriter: ...
@overload
@@ -180,13 +173,12 @@ def open(
*,
mode: Literal["w", "a"],
interleaved: Literal[True],
- fileformat: Optional[str] = ...,
- qualities: Optional[bool] = ...,
+ fileformat: str | None = ...,
+ qualities: bool | None = ...,
opener=...,
compression_level: int = ...,
open_threads: int = ...,
-) -> PairedEndWriter:
- ...
+) -> PairedEndWriter: ...
@overload
@@ -196,36 +188,35 @@ def open(
_file3: _FileOrPath,
*files: _FileOrPath,
mode: Literal["w", "a"],
- fileformat: Optional[str] = ...,
+ fileformat: str | None = ...,
interleaved: Literal[False] = ...,
- qualities: Optional[bool] = ...,
+ qualities: bool | None = ...,
opener=...,
compression_level: int = ...,
open_threads: int = ...,
-) -> MultipleFileWriter:
- ...
+) -> MultipleFileWriter: ...
def open(
*files: _FileOrPath,
- file1: Optional[_FileOrPath] = None,
- file2: Optional[_FileOrPath] = None,
- fileformat: Optional[str] = None,
+ file1: _FileOrPath | None = None,
+ file2: _FileOrPath | None = None,
+ fileformat: str | None = None,
interleaved: bool = False,
mode: str = "r",
- qualities: Optional[bool] = None,
+ qualities: bool | None = None,
opener=xopen,
compression_level: int = 1,
open_threads: int = 0,
**_kwargs, # TODO Can we get rid of this? Only here to satisfy type checker
-) -> Union[
- SingleEndReader,
- PairedEndReader,
- SingleEndWriter,
- PairedEndWriter,
- MultipleFileReader,
- MultipleFileWriter,
-]:
+) -> (
+ SingleEndReader
+ | PairedEndReader
+ | SingleEndWriter
+ | PairedEndWriter
+ | MultipleFileReader
+ | MultipleFileWriter
+):
"""
Open one or more FASTQ or FASTA files for reading or writing,
or open one (unaligned) BAM file for reading.
=====================================
src/dnaio/_core.pyi
=====================================
@@ -1,24 +1,18 @@
-import sys
from typing import (
Generic,
- Optional,
- Tuple,
BinaryIO,
- Iterator,
- Type,
TypeVar,
- ByteString,
)
+from collections.abc import Iterator
class SequenceRecord:
name: str
sequence: str
- qualities: Optional[str]
+ qualities: str | None
def __init__(
- self, name: str, sequence: str, qualities: Optional[str] = ...
+ self, name: str, sequence: str, qualities: str | None = ...
) -> None: ...
def __getitem__(self, s: slice) -> SequenceRecord: ...
- def __repr__(self) -> str: ...
def __len__(self) -> int: ...
def __richcmp__(self, other: SequenceRecord, op: int) -> bool: ...
def qualities_as_bytes(self) -> bytes: ...
@@ -28,16 +22,12 @@ class SequenceRecord:
@property
def id(self) -> str: ...
@property
- def comment(self) -> Optional[str]: ...
+ def comment(self) -> str | None: ...
-# Bytestring = Union[bytes, bytearray, memoryview]. Technically just 'bytes' is
-# acceptable as an alias, but even more technically this function supports all
-# types that implement the buffer protocol, for which there is no type yet.
-# See: https://github.com/python/typing/issues/593
def paired_fastq_heads(
- buf1: ByteString, buf2: ByteString, end1: int, end2: int
-) -> Tuple[int, int]: ...
-def bam_head(buf: bytes, end: Optional[int] = None) -> int: ...
+ buf1: bytes | bytearray, buf2: bytes | bytearray, end1: int, end2: int
+) -> tuple[int, int]: ...
+def bam_head(buf: bytes | bytearray, end: int | None = None) -> int: ...
def records_are_mates(
__first_record: SequenceRecord,
__second_record: SequenceRecord,
@@ -48,7 +38,7 @@ T = TypeVar("T")
class FastqIter(Generic[T]):
def __init__(
- self, file: BinaryIO, sequence_class: Type[T], buffer_size: int = ...
+ self, file: BinaryIO, sequence_class: type[T], buffer_size: int = ...
): ...
def __iter__(self) -> Iterator[T]: ...
def __next__(self) -> T: ...
=====================================
src/dnaio/_util.py
=====================================
@@ -1,5 +1,4 @@
def shorten(s: str, n: int = 100) -> str:
-
"""Shorten string s to at most n characters, appending "..." if necessary."""
if s is None:
return None
=====================================
src/dnaio/chunks.py
=====================================
@@ -7,7 +7,7 @@ or subprocess and be parsed and processed there.
"""
from io import BufferedIOBase
-from typing import Optional, Iterator, Tuple
+from collections.abc import Iterator
from ._bam import read_bam_header_after_magic
from ._core import paired_fastq_heads as _paired_fastq_heads
@@ -15,7 +15,7 @@ from ._core import bam_head as _bam_head
from .exceptions import FileFormatError, FastaFormatError, UnknownFileFormat
-def _fasta_head(buf: bytes, end: Optional[int] = None) -> int:
+def _fasta_head(buf: bytes | bytearray, end: int | None = None) -> int:
"""
Search for the end of the last complete FASTA record within buf[:end]
@@ -37,8 +37,8 @@ def _fasta_head(buf: bytes, end: Optional[int] = None) -> int:
def _paired_fasta_heads(
- buf1: bytes, buf2: bytes, end1: int, end2: int
-) -> Tuple[int, int]:
+ buf1: bytes | bytearray, buf2: bytes | bytearray, end1: int, end2: int
+) -> tuple[int, int]:
"""
Return positions pos1, pos2 where right1 <= end1 and right2 <= end2
such that buf1[:pos1] and buf2[:pos2] contain the same number of complete FASTA
@@ -64,7 +64,7 @@ def _paired_fasta_heads(
return (pos1, pos2)
-def _fastq_head(buf: bytes, end: Optional[int] = None) -> int:
+def _fastq_head(buf: bytes | bytearray, end: int | None = None) -> int:
"""
Search for the end of the last complete *two* FASTQ records in buf[:end].
@@ -163,7 +163,7 @@ def read_paired_chunks(
f: BufferedIOBase,
f2: BufferedIOBase,
buffer_size: int = 4 * 1024**2,
-) -> Iterator[Tuple[memoryview, memoryview]]:
+) -> Iterator[tuple[memoryview, memoryview]]:
"""
Read chunks of paired-end FASTA or FASTQ records from two files.
A pair of chunks (memoryview objects) is yielded on each iteration,
=====================================
src/dnaio/exceptions.py
=====================================
@@ -1,6 +1,3 @@
-from typing import Optional
-
-
class UnknownFileFormat(Exception):
"""
The file format could not be automatically detected
@@ -19,7 +16,7 @@ class FileFormatError(Exception):
format = "sequence" # Something generic that works for both FASTA and FASTQ
- def __init__(self, msg: str, line: Optional[int]):
+ def __init__(self, msg: str, line: int | None):
super().__init__(msg, line)
self.message = msg
self.line = line # starts at 0!
=====================================
src/dnaio/interfaces.py
=====================================
@@ -1,6 +1,6 @@
from abc import abstractmethod
from contextlib import AbstractContextManager
-from typing import Iterable, Iterator, Tuple
+from collections.abc import Iterable, Iterator
from dnaio import SequenceRecord
@@ -29,7 +29,7 @@ class SingleEndReader(AbstractContextManager):
class PairedEndReader(AbstractContextManager):
@abstractmethod
- def __iter__(self) -> Iterator[Tuple[SequenceRecord, SequenceRecord]]:
+ def __iter__(self) -> Iterator[tuple[SequenceRecord, SequenceRecord]]:
"""
Iterate over an input containing paired-end records
@@ -90,7 +90,7 @@ class MultipleFileWriter(AbstractContextManager):
"""
@abstractmethod
- def write_iterable(self, list_of_records: Iterable[Tuple[SequenceRecord, ...]]):
+ def write_iterable(self, list_of_records: Iterable[tuple[SequenceRecord, ...]]):
"""
Iterate over the list (or other iterable container) and write all
N-tuples of SequenceRecord to disk. N must be equal
=====================================
src/dnaio/multipleend.py
=====================================
@@ -1,7 +1,8 @@
import contextlib
import os
from os import PathLike
-from typing import BinaryIO, IO, Iterable, Iterator, List, Optional, Tuple, Union
+from typing import BinaryIO, IO
+from collections.abc import Iterable, Iterator
from xopen import xopen
@@ -14,10 +15,10 @@ from .writers import FastaWriter, FastqWriter
def _open_multiple(
- *files: Union[str, PathLike, BinaryIO],
- fileformat: Optional[str] = None,
+ *files: str | PathLike | BinaryIO,
+ fileformat: str | None = None,
mode: str = "r",
- qualities: Optional[bool] = None,
+ qualities: bool | None = None,
opener=xopen,
):
if not files:
@@ -48,15 +49,15 @@ class MultipleFileReader:
def __init__(
self,
- *files: Union[str, PathLike, BinaryIO],
- fileformat: Optional[str] = None,
+ *files: str | PathLike | BinaryIO,
+ fileformat: str | None = None,
opener=xopen,
):
if len(files) < 1:
raise ValueError("At least one file is required")
self._files = files
self._stack = contextlib.ExitStack()
- self._readers: List[Union[FastaReader, FastqReader]] = [
+ self._readers: list[FastaReader | FastqReader] = [
self._stack.enter_context(
_open_single(file, opener=opener, fileformat=fileformat, mode="r")
)
@@ -70,7 +71,7 @@ class MultipleFileReader:
f"({', '.join(repr(reader) for reader in self._readers)})"
)
- def __iter__(self) -> Iterator[Tuple[SequenceRecord, ...]]:
+ def __iter__(self) -> Iterator[tuple[SequenceRecord, ...]]:
"""
Iterate over multiple inputs containing records
@@ -131,7 +132,7 @@ class MultipleFastaWriter(MultipleFileWriter):
def __init__(
self,
- *files: Union[str, PathLike, BinaryIO],
+ *files: str | PathLike | BinaryIO,
opener=xopen,
append: bool = False,
):
@@ -141,7 +142,7 @@ class MultipleFastaWriter(MultipleFileWriter):
self._files = files
self._number_of_files = len(files)
self._stack = contextlib.ExitStack()
- self._writers: List[Union[FastaWriter, FastqWriter]] = [
+ self._writers: list[FastaWriter | FastqWriter] = [
self._stack.enter_context(
_open_single(
file,
@@ -169,7 +170,7 @@ class MultipleFastaWriter(MultipleFileWriter):
for record, writer in zip(records, self._writers):
writer.write(record)
- def write_iterable(self, records_iterable: Iterable[Tuple[SequenceRecord, ...]]):
+ def write_iterable(self, records_iterable: Iterable[tuple[SequenceRecord, ...]]):
for records in records_iterable:
self.write(*records)
@@ -190,7 +191,7 @@ class MultipleFastqWriter(MultipleFileWriter):
def __init__(
self,
- *files: Union[str, PathLike, BinaryIO],
+ *files: str | PathLike | BinaryIO,
opener=xopen,
append: bool = False,
):
@@ -200,7 +201,7 @@ class MultipleFastqWriter(MultipleFileWriter):
self._files = files
self._number_of_files = len(files)
self._stack = contextlib.ExitStack()
- self._writers: List[IO] = [
+ self._writers: list[IO] = [
self._stack.enter_context(
opener(file, mode + "b") if not hasattr(file, "write") else file # type: ignore
)
@@ -221,7 +222,7 @@ class MultipleFastqWriter(MultipleFileWriter):
for record, writer in zip(records, self._writers):
writer.write(record.fastq_bytes())
- def write_iterable(self, records_iterable: Iterable[Tuple[SequenceRecord, ...]]):
+ def write_iterable(self, records_iterable: Iterable[tuple[SequenceRecord, ...]]):
# Use faster methods for more common cases before falling back to
# generic multiple files mode (which is much slower due to calling the
# zip function).
=====================================
src/dnaio/pairedend.py
=====================================
@@ -1,6 +1,7 @@
from contextlib import ExitStack
from os import PathLike
-from typing import Union, BinaryIO, Optional, Iterator, Tuple
+from typing import BinaryIO
+from collections.abc import Iterator
from xopen import xopen
@@ -13,12 +14,12 @@ from .singleend import _open_single
def _open_paired(
- *files: Union[str, PathLike, BinaryIO],
- fileformat: Optional[str] = None,
+ *files: str | PathLike | BinaryIO,
+ fileformat: str | None = None,
mode: str = "r",
- qualities: Optional[bool] = None,
+ qualities: bool | None = None,
opener=xopen,
-) -> Union[PairedEndReader, PairedEndWriter]:
+) -> PairedEndReader | PairedEndWriter:
"""
Open paired-end reads
"""
@@ -65,11 +66,11 @@ class TwoFilePairedEndReader(PairedEndReader):
def __init__(
self,
- file1: Union[str, PathLike, BinaryIO],
- file2: Union[str, PathLike, BinaryIO],
+ file1: str | PathLike | BinaryIO,
+ file2: str | PathLike | BinaryIO,
*,
mode="r",
- fileformat: Optional[str] = None,
+ fileformat: str | None = None,
opener=xopen,
):
self.mode = mode
@@ -86,7 +87,7 @@ class TwoFilePairedEndReader(PairedEndReader):
def __repr__(self) -> str:
return f"{self.__class__.__name__}(file1={self.reader1}, file2={self.reader2})"
- def __iter__(self) -> Iterator[Tuple[SequenceRecord, SequenceRecord]]:
+ def __iter__(self) -> Iterator[tuple[SequenceRecord, SequenceRecord]]:
"""
Iterate over the paired reads.
Each yielded item is a pair of `SequenceRecord` objects.
@@ -146,10 +147,10 @@ class InterleavedPairedEndReader(PairedEndReader):
def __init__(
self,
- file: Union[str, PathLike, BinaryIO],
+ file: str | PathLike | BinaryIO,
*,
mode="r",
- fileformat: Optional[str] = None,
+ fileformat: str | None = None,
opener=xopen,
):
self.mode = mode
@@ -161,7 +162,7 @@ class InterleavedPairedEndReader(PairedEndReader):
def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.reader})"
- def __iter__(self) -> Iterator[Tuple[SequenceRecord, SequenceRecord]]:
+ def __iter__(self) -> Iterator[tuple[SequenceRecord, SequenceRecord]]:
it = iter(self.reader)
for r1 in it:
try:
@@ -200,18 +201,18 @@ class TwoFilePairedEndWriter(PairedEndWriter):
def __init__(
self,
- file1: Union[str, PathLike, BinaryIO],
- file2: Union[str, PathLike, BinaryIO],
+ file1: str | PathLike | BinaryIO,
+ file2: str | PathLike | BinaryIO,
*,
- fileformat: Optional[str] = "fastq",
- qualities: Optional[bool] = None,
+ fileformat: str | None = "fastq",
+ qualities: bool | None = None,
opener=xopen,
append: bool = False,
):
mode = "a" if append else "w"
with ExitStack() as stack:
- self._writer1: Union[FastaWriter, FastqWriter]
- self._writer2: Union[FastaWriter, FastqWriter]
+ self._writer1: FastaWriter | FastqWriter
+ self._writer2: FastaWriter | FastqWriter
self._writer1 = stack.enter_context(
_open_single(
file1,
@@ -260,10 +261,10 @@ class InterleavedPairedEndWriter(PairedEndWriter):
def __init__(
self,
- file: Union[str, PathLike, BinaryIO],
+ file: str | PathLike | BinaryIO,
*,
- fileformat: Optional[str] = "fastq",
- qualities: Optional[bool] = None,
+ fileformat: str | None = "fastq",
+ qualities: bool | None = None,
opener=xopen,
append: bool = False,
):
=====================================
src/dnaio/readers.py
=====================================
@@ -1,11 +1,13 @@
"""
Classes for reading FASTA and FASTQ files
"""
+
__all__ = ["FastaReader", "FastqReader"]
import io
from os import PathLike
-from typing import Union, BinaryIO, Optional, Iterator, List
+from typing import BinaryIO
+from collections.abc import Iterator
from xopen import xopen
@@ -26,10 +28,10 @@ class BinaryFileReader:
def __init__(
self,
- file: Union[PathLike, str, BinaryIO],
+ file: PathLike | str | BinaryIO,
*,
opener=xopen,
- _close_file: Optional[bool] = None,
+ _close_file: bool | None = None,
):
"""
The file is a path or a file-like object. In both cases, the file may
@@ -71,12 +73,12 @@ class FastaReader(BinaryFileReader, SingleEndReader):
def __init__(
self,
- file: Union[PathLike, str, BinaryIO],
+ file: PathLike | str | BinaryIO,
*,
keep_linebreaks: bool = False,
sequence_class=SequenceRecord,
opener=xopen,
- _close_file: Optional[bool] = None,
+ _close_file: bool | None = None,
):
"""
file is a path or a file-like object. In both cases, the file may
@@ -96,7 +98,7 @@ class FastaReader(BinaryFileReader, SingleEndReader):
Iterate over the records in this FASTA file.
"""
name = None
- seq: List[str] = []
+ seq: list[str] = []
if self._file.closed:
return
for i, line in enumerate(self._file):
@@ -145,12 +147,12 @@ class FastqReader(BinaryFileReader, SingleEndReader):
def __init__(
self,
- file: Union[PathLike, str, BinaryIO],
+ file: PathLike | str | BinaryIO,
*,
sequence_class=SequenceRecord,
buffer_size: int = 128 * 1024, # Buffer size used by cat, pigz etc.
opener=xopen,
- _close_file: Optional[bool] = None,
+ _close_file: bool | None = None,
):
"""
file is a filename or a file-like object.
@@ -206,12 +208,12 @@ class BamReader(BinaryFileReader, SingleEndReader):
def __init__(
self,
- file: Union[PathLike, str, BinaryIO],
+ file: PathLike | str | BinaryIO,
*,
sequence_class=SequenceRecord,
buffer_size: int = 128 * 1024, # Buffer size used by cat, pigz etc.
opener=xopen,
- _close_file: Optional[bool] = None,
+ _close_file: bool | None = None,
with_header: bool = True,
):
super().__init__(file, opener=opener, _close_file=_close_file)
=====================================
src/dnaio/singleend.py
=====================================
@@ -1,19 +1,19 @@
import os
-from typing import Optional, Union, BinaryIO, Tuple
+from typing import BinaryIO
from .exceptions import UnknownFileFormat
from .readers import BamReader, FastaReader, FastqReader
from .writers import FastaWriter, FastqWriter
-def _open_single( # noqa: C901
- file_or_path: Union[str, os.PathLike, BinaryIO],
+def _open_single(
+ file_or_path: str | os.PathLike | BinaryIO,
opener,
*,
- fileformat: Optional[str] = None,
+ fileformat: str | None = None,
mode: str = "r",
- qualities: Optional[bool] = None,
-) -> Union[BamReader, FastaReader, FastaWriter, FastqReader, FastqWriter]:
+ qualities: bool | None = None,
+) -> BamReader | FastaReader | FastaWriter | FastqReader | FastqWriter:
"""
Open a single sequence file.
"""
@@ -77,9 +77,9 @@ def _open_single( # noqa: C901
def _open_file_or_path(
- file_or_path: Union[str, os.PathLike, BinaryIO], mode: str, opener
-) -> Tuple[bool, BinaryIO, Optional[str]]:
- path: Optional[str]
+ file_or_path: str | os.PathLike | BinaryIO, mode: str, opener
+) -> tuple[bool, BinaryIO, str | None]:
+ path: str | None
file: BinaryIO
try:
path = os.fspath(file_or_path) # type: ignore
@@ -101,7 +101,7 @@ def _open_file_or_path(
return close_file, file, path
-def _detect_format_from_name(name: str) -> Optional[str]:
+def _detect_format_from_name(name: str) -> str | None:
"""
name -- file name
@@ -122,7 +122,7 @@ def _detect_format_from_name(name: str) -> Optional[str]:
return None
-def _detect_format_from_content(file: BinaryIO) -> Optional[str]:
+def _detect_format_from_content(file: BinaryIO) -> str | None:
"""
Return 'fasta', 'fastq' or None
"""
@@ -136,7 +136,7 @@ def _detect_format_from_content(file: BinaryIO) -> Optional[str]:
if magic.startswith(b"@") or magic == b"":
# Pretend FASTQ for empty input
return "fastq"
- elif magic.startswith(b">") or magic.startswith(b"#"):
+ elif magic.startswith((b">", b"#")):
# Some FASTA variants allow comments
return "fasta"
elif magic == b"BAM\1":
=====================================
src/dnaio/writers.py
=====================================
@@ -1,6 +1,6 @@
import os
from os import PathLike
-from typing import Union, BinaryIO, Optional
+from typing import BinaryIO
from xopen import xopen
@@ -17,10 +17,10 @@ class FileWriter:
def __init__(
self,
- file: Union[PathLike, str, BinaryIO],
+ file: PathLike | str | BinaryIO,
*,
opener=xopen,
- _close_file: Optional[bool] = None,
+ _close_file: bool | None = None,
):
try:
os.fspath(file) # type: ignore
@@ -62,11 +62,11 @@ class FastaWriter(FileWriter, SingleEndWriter):
def __init__(
self,
- file: Union[PathLike, str, BinaryIO],
+ file: PathLike | str | BinaryIO,
*,
- line_length: Optional[int] = None,
+ line_length: int | None = None,
opener=xopen,
- _close_file: Optional[bool] = None,
+ _close_file: bool | None = None,
):
super().__init__(file, opener=opener, _close_file=_close_file)
self.line_length = line_length if line_length != 0 else None
@@ -74,7 +74,7 @@ class FastaWriter(FileWriter, SingleEndWriter):
def __repr__(self) -> str:
return f"FastaWriter('{getattr(self._file, 'name', self._file)}')"
- def write(self, name_or_record, sequence: Optional[str] = None):
+ def write(self, name_or_record, sequence: str | None = None):
"""Write a record to the FASTA file.
If only one parameter (name_or_record) is given, it must have
@@ -121,16 +121,16 @@ class FastqWriter(FileWriter, SingleEndWriter):
def __init__(
self,
- file: Union[PathLike, str, BinaryIO],
+ file: PathLike | str | BinaryIO,
*,
two_headers: bool = False,
opener=xopen,
- _close_file: Optional[bool] = None,
+ _close_file: bool | None = None,
):
super().__init__(file, opener=opener, _close_file=_close_file)
self._two_headers = two_headers
# setattr avoids a complaint from Mypy
- setattr(
+ setattr( # noqa: B010
self, "write", self._write_two_headers if self._two_headers else self._write
)
=====================================
tests/test_chunks.py
=====================================
@@ -61,9 +61,7 @@ def test_paired_fasta_heads():
assert pheads(b">r\nA\n>s", b">r\nCT\n>s") == (5, 6)
assert pheads(b">r\nA\n>s\nG\n>t\n", b">r\nCT\n>s") == (5, 6)
- buf1 = (
- textwrap.dedent(
- """
+ buf1 = textwrap.dedent("""
>1
a
b
@@ -71,25 +69,15 @@ def test_paired_fasta_heads():
c
>3
uv
- """
- )
- .strip()
- .encode()
- )
- buf2 = (
- textwrap.dedent(
- """
+ """).strip().encode()
+ buf2 = textwrap.dedent("""
>1
def
>2
gh
i
>3
- """
- )
- .strip()
- .encode()
- )
+ """).strip().encode()
assert pheads(buf1, buf2) == (
len(b">1\na\nb\n>2\nc\n"),
=====================================
tests/test_internal.py
=====================================
@@ -58,34 +58,26 @@ class TestFastaReader:
assert reads == simple_fasta
def test_with_comments(self) -> None:
- fasta = BytesIO(
- dedent(
- """
+ fasta = BytesIO(dedent("""
# a comment
# another one
>first_sequence
SEQUENCE1
>second_sequence
SEQUENCE2
- """
- ).encode()
- )
+ """).encode())
reads = list(FastaReader(fasta))
assert reads == simple_fasta
def test_wrong_format(self) -> None:
- fasta = BytesIO(
- dedent(
- """# a comment
+ fasta = BytesIO(dedent("""# a comment
# another one
unexpected
>first_sequence
SEQUENCE1
>second_sequence
SEQUENCE2
- """
- ).encode()
- )
+ """).encode())
with raises(FastaFormatError) as info:
list(FastaReader(fasta))
assert info.value.line == 2
@@ -440,7 +432,7 @@ class TestFastaWriter:
bio = BytesIO()
with FastaWriter(bio) as fw:
fw.write(SequenceRecord("name", ""))
- assert bio.getvalue() == b">name\n\n", "{!r}".format(bio.getvalue())
+ assert bio.getvalue() == b">name\n\n", f"{bio.getvalue()!r}"
class TestFastqWriter:
=====================================
tests/test_open.py
=====================================
@@ -33,9 +33,9 @@ SIMPLE_RECORDS = {
def formatted_sequence(record, fileformat) -> str:
if fileformat == "fastq":
- return "@{}\n{}\n+\n{}\n".format(record.name, record.sequence, record.qualities)
+ return f"@{record.name}\n{record.sequence}\n+\n{record.qualities}\n"
else:
- return ">{}\n{}\n".format(record.name, record.sequence)
+ return f">{record.name}\n{record.sequence}\n"
def formatted_sequences(records, fileformat) -> str:
@@ -346,7 +346,7 @@ def make_random_fasta(path, n_records) -> None:
with xopen(path, "w") as f:
for i in range(n_records):
- name = "sequence_{}".format(i)
+ name = f"sequence_{i}"
sequence = "".join(choice("ACGT") for _ in range(300))
print(">", name, "\n", sequence, sep="", file=f)
=====================================
tests/test_records.py
=====================================
@@ -121,7 +121,6 @@ class TestSequenceRecord:
(SequenceRecord("name", "A", "="), None),
(SequenceRecord("name ", "A", "="), None),
(SequenceRecord("name ", "A", "="), None),
- (SequenceRecord("name", "A", "="), None),
(SequenceRecord("AotC I hate sand!", "A", "="), "I hate sand!"),
(
SequenceRecord("Givemesome space", "A", "="),
@@ -138,7 +137,6 @@ class TestSequenceRecord:
(SequenceRecord("name", "A", "="), "name"),
(SequenceRecord("name ", "A", "="), "name"),
(SequenceRecord("name ", "A", "="), "name"),
- (SequenceRecord("name", "A", "="), "name"),
(SequenceRecord("AotC I hate sand!", "A", "="), "AotC"),
],
)
=====================================
tox.ini deleted
=====================================
@@ -1,53 +0,0 @@
-[tox]
-envlist = flake8,black,mypy,docs,py310,py311,py312,py313,py314
-isolated_build = True
-
-[testenv]
-deps =
- pytest
- coverage
-commands =
- coverage run -m pytest
- coverage combine
- coverage xml
- coverage report
-setenv = PYTHONDEVMODE = 1
-
-[testenv:flake8]
-basepython = python3.10
-deps = flake8
-commands = flake8 src/ tests/
-
-[testenv:black]
-basepython = python3.10
-deps = black==22.3.0
-skip_install = true
-commands = black --check src/ tests/ doc/ helpers/ setup.py
-
-[testenv:mypy]
-basepython = python3.10
-deps =
- mypy
- pytest
-commands = mypy src/ tests/
-
-[testenv:asan]
-setenv=
- PYTHONDEVMODE=1
- PYTHONMALLOC=malloc
- CFLAGS=-lasan -fsanitize=address -fno-omit-frame-pointer
-allowlist_externals=bash
-commands=
- bash -c 'export LD_PRELOAD=$(gcc -print-file-name=libasan.so) && printenv LD_PRELOAD && python -c "import dnaio" && pytest tests'
-
-[testenv:docs]
-basepython = python3.10
-changedir = doc
-deps = -r doc/requirements.txt
-commands = sphinx-build -W -d {envtmpdir}/doctrees . {envtmpdir}/html
-
-[flake8]
-max-line-length = 99
-max-complexity = 15
-# E203 (whitespace before ':') must be ignored for Black
-extend-ignore = E203
=====================================
tox.toml
=====================================
@@ -0,0 +1,43 @@
+env_list = ["ruff", "black", "mypy", "docs", "py311", "py312", "py313", "py314", "py314t", "py315", "py315t"]
+
+[env_run_base]
+default_base_python = "3.15"
+deps = [
+ "pytest",
+ "coverage",
+]
+commands = [
+ ["coverage", "run", "-m", "pytest"],
+ ["coverage", "combine"],
+ ["coverage", "xml"],
+ ["coverage", "report"],
+]
+set_env = { PYTHONDEVMODE = "1" }
+
+[env.ruff]
+skip_install = true
+deps = ["ruff"]
+commands = [["ruff", "check", "src/", "tests/", "setup.py"]]
+
+[env.black]
+deps = ["black==26.10.1"]
+skip_install = true
+commands = [["black", "--check", "src/", "tests/", "doc/", "helpers/", "setup.py"]]
+
+[env.mypy]
+deps = ["mypy", "pytest"]
+commands = [["mypy", "src/", "tests/"]]
+
+[env.asan]
+set_env = {PYTHONDEVMODE="1", PYTHONMALLOC="malloc", CFLAGS="-lasan -fsanitize=address -fno-omit-frame-pointer"}
+allowlist_externals = ["bash"]
+commands = [
+ ["bash", "-c", "export LD_PRELOAD=$(gcc -print-file-name=libasan.so) && printenv LD_PRELOAD && python -c 'import dnaio' && pytest tests"]
+]
+
+[env.docs]
+changedir = "doc"
+deps = ["-r doc/requirements.txt"]
+commands = [
+ ["sphinx-build", "-W", "-d", "{envtmpdir}/doctrees", ".", "{envtmpdir}/html"]
+]
View it on GitLab: https://salsa.debian.org/med-team/python-dnaio/-/compare/9383b1a909727475010772064021cf7e900db31f...47bdec908db295f973cf58b7081bbece9b2e56e2
--
View it on GitLab: https://salsa.debian.org/med-team/python-dnaio/-/compare/9383b1a909727475010772064021cf7e900db31f...47bdec908db295f973cf58b7081bbece9b2e56e2
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261113/0c2b6b24/attachment-0001.htm>
More information about the debian-med-commit
mailing list