diff options
| author | pi coding agent <pi@localhost> | 2026-10-15 20:44:47 +0000 |
|---|---|---|
| committer | Frederick Muriuki Muriithi <fredmanglis@gmail.com> | 2026-10-15 16:01:45 -0500 |
| commit | 6058bcb6c11060647819a1790b05f4ea144bb2b3 (patch) | |
| tree | 7fcfedcc14d01f7dac5ce3b9dcfe4484c6949e10 /scripts | |
| parent | 87ba0e2fae57764863af2c978a8878f92f043ab2 (diff) | |
| download | gn-uploader-6058bcb6c11060647819a1790b05f4ea144bb2b3.tar.gz | |
Relax line-argument annotations to any iterable
Accept `Iterable[str]` for the lines arguments instead of `Iterator[str]`, since lists of lines are valid inputs, and accept `Sequence[str]` for the sample names. This fixes the mypy type errors without changing behaviour.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/genotypes/preprocess_csv_collect_info.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/genotypes/preprocess_csv_collect_info.py b/scripts/genotypes/preprocess_csv_collect_info.py index b153279..6b3b574 100644 --- a/scripts/genotypes/preprocess_csv_collect_info.py +++ b/scripts/genotypes/preprocess_csv_collect_info.py @@ -6,7 +6,7 @@ import logging import multiprocessing as mproc from pathlib import Path from dataclasses import asdict, dataclass, field, fields -from typing import Union, Iterable, Iterator, Optional, Callable +from typing import Union, Iterable, Iterator, Optional, Callable, Sequence from argparse import Namespace, ArgumentParser from gn_libs.cli import SysExit @@ -209,7 +209,7 @@ class _ChunkStats:# pylint: disable=[too-many-instance-attributes] def _accumulate( headers: tuple[str, ...], fileconfigs: dict, - lines: Iterator[str] + lines: Iterable[str] ) -> _ChunkStats: """Accumulate statistics from the provided lines.""" is_skippable_line = _make_is_skippable_line(fileconfigs, headers) @@ -292,7 +292,7 @@ def _merge_all_chunk_stats( def _read_chunks( - lines: Iterator[str], + lines: Iterable[str], chunk_size: int ) -> Iterator[list[str]]: """Group the lines into chunks of at most ``chunk_size`` lines.""" @@ -319,7 +319,7 @@ def _process_chunk(args: tuple[tuple[str, ...], dict, list[str]]) -> _ChunkStats def file_stats_multiprocessing( fileconfigs: dict, headers: tuple[str, ...], - lines: Iterator[str], + lines: Iterable[str], chunk_size: int = MULTIPROCESSING_CHUNK_SIZE ) -> FileStats: """File stats from the lines in the file using multiple processes.""" @@ -338,7 +338,7 @@ def file_stats_multiprocessing( def _as_file_stats( stats: _ChunkStats, - samples: tuple[str, ...], + samples: Sequence[str], header_errors: tuple[LineError, ...] ) -> FileStats: """Convert accumulated statistics into file statistics.""" @@ -385,7 +385,7 @@ def parse_dot_geno_line(line) -> dict[str, str]: def file_stats_singlethread( fileconfigs: dict, headers: tuple[str, ...], - lines: Iterator[str] + lines: Iterable[str] ) -> FileStats: """File stats from the lines in the file using a single-threaded process.""" logger.debug("THE FILE HEADERS: %s", headers) |
