Skip to content

Commit b815d54

Browse files
committed
Formatting fixes from ruff
1 parent 7c080d4 commit b815d54

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

bio2zarr/plink.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ def validate(bed_path, zarr_path):
185185
assert call_genotype.shape[2] == 2
186186

187187
row_id = 0
188-
for bed_row, zarr_row in zip(bed_genotypes, call_genotype):
188+
for bed_row, zarr_row in zip(bed_genotypes, call_genotype, strict=False):
189189
# print("ROW", row_id)
190190
# print(bed_row, zarr_row)
191191
row_id += 1
192-
for bed_call, zarr_call in zip(bed_row, zarr_row):
192+
for bed_call, zarr_call in zip(bed_row, zarr_row, strict=False):
193193
if bed_call == -127:
194194
assert list(zarr_call) == [-1, -1]
195195
elif bed_call == 0:

bio2zarr/typing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
from pathlib import Path
2-
from typing import Union
32

4-
PathType = Union[str, Path]
3+
PathType = str | Path

bio2zarr/vcf2zarr/icf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def scan_vcf(path, target_num_partitions, *, local_alleles):
289289
samples=[Sample(sample_id) for sample_id in vcf.samples],
290290
contigs=[
291291
Contig(contig_id, length)
292-
for contig_id, length in zip(vcf.seqnames, contig_lengths)
292+
for contig_id, length in zip(vcf.seqnames, contig_lengths, strict=False)
293293
],
294294
filters=filters,
295295
fields=fields,
@@ -764,7 +764,9 @@ def chunks(self, partition_id, start_chunk=0):
764764
chunk_cumulative_records = self.chunk_record_index(partition_id)
765765
chunk_num_records = np.diff(chunk_cumulative_records)
766766
for count, cumulative in zip(
767-
chunk_num_records[start_chunk:], chunk_cumulative_records[start_chunk + 1 :]
767+
chunk_num_records[start_chunk:],
768+
chunk_cumulative_records[start_chunk + 1 :],
769+
strict=False,
768770
):
769771
path = partition_path / f"{cumulative}"
770772
chunk = self.read_chunk(path)

bio2zarr/vcf2zarr/vcz.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ def encode_alleles_partition(self, partition_index):
760760
for ref, alt in zip(
761761
ref_field.iter_values(partition.start, partition.stop),
762762
alt_field.iter_values(partition.start, partition.stop),
763+
strict=False,
763764
):
764765
j = alleles.next_buffer_row()
765766
alleles.buff[j, :] = constants.STR_FILL

bio2zarr/vcf2zarr/verification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def assert_format_val_equal(vcf_val, zarr_val, vcf_type, vcf_number):
114114
assert isinstance(vcf_val, np.ndarray)
115115
if vcf_type in ("String", "Character"):
116116
assert len(vcf_val) == len(zarr_val)
117-
for v, z in zip(vcf_val, zarr_val):
117+
for v, z in zip(vcf_val, zarr_val, strict=False):
118118
if vcf_number == "1":
119119
assert v == z
120120
else:

bio2zarr/vcf_utils.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from collections.abc import Sequence
88
from dataclasses import dataclass
99
from enum import Enum
10-
from typing import IO, Any, Optional, Union
10+
from typing import IO, Any
1111

1212
import cyvcf2
1313
import humanfriendly
@@ -33,7 +33,7 @@ def get_file_offset(vfp: int) -> int:
3333
return vfp >> 16 & address_mask
3434

3535

36-
def read_bytes_as_value(f: IO[Any], fmt: str, nodata: Optional[Any] = None) -> Any:
36+
def read_bytes_as_value(f: IO[Any], fmt: str, nodata: Any | None = None) -> Any:
3737
"""Read bytes using a `struct` format string and return the unpacked data value.
3838
3939
Parameters
@@ -85,8 +85,8 @@ class Region:
8585
"""
8686

8787
contig: str
88-
start: Optional[int] = None
89-
end: Optional[int] = None
88+
start: int | None = None
89+
end: int | None = None
9090

9191
def __post_init__(self):
9292
if self.start is not None:
@@ -194,9 +194,7 @@ def get_first_locus_in_bin(csi: CSIIndex, bin: int) -> int:
194194
return (bin - first_bin_on_level) * (max_span // level_size) + 1
195195

196196

197-
def read_csi(
198-
file: PathType, storage_options: Optional[dict[str, str]] = None
199-
) -> CSIIndex:
197+
def read_csi(file: PathType, storage_options: dict[str, str] | None = None) -> CSIIndex:
200198
"""Parse a CSI file into a `CSIIndex` object.
201199
202200
Parameters
@@ -311,7 +309,7 @@ def offsets(self) -> Any:
311309

312310

313311
def read_tabix(
314-
file: PathType, storage_options: Optional[dict[str, str]] = None
312+
file: PathType, storage_options: dict[str, str] | None = None
315313
) -> TabixIndex:
316314
"""Parse a tabix file into a `TabixIndex` object.
317315
@@ -452,7 +450,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
452450
return False
453451

454452
def contig_record_counts(self):
455-
d = dict(zip(self.sequence_names, self.index.record_counts))
453+
d = dict(zip(self.sequence_names, self.index.record_counts, strict=False))
456454
if self.file_type == VcfFileType.BCF:
457455
d = {k: v for k, v in d.items() if v > 0}
458456
return d
@@ -483,8 +481,8 @@ def _filter_empty_and_refine(self, regions):
483481

484482
def partition_into_regions(
485483
self,
486-
num_parts: Optional[int] = None,
487-
target_part_size: Union[None, int, str] = None,
484+
num_parts: int | None = None,
485+
target_part_size: None | int | str = None,
488486
):
489487
if num_parts is None and target_part_size is None:
490488
raise ValueError("One of num_parts or target_part_size must be specified")

0 commit comments

Comments
 (0)