77from collections .abc import Sequence
88from dataclasses import dataclass
99from enum import Enum
10- from typing import IO , Any
10+ from typing import IO , Any , Optional , Union
1111
1212import cyvcf2
1313import 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 : Any | None = None ) -> Any :
36+ def read_bytes_as_value (f : IO [Any ], fmt : str , nodata : Optional [ Any ] = 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 : int | None = None
89- end : int | None = None
88+ start : Optional [ int ] = None
89+ end : Optional [ int ] = None
9090
9191 def __post_init__ (self ):
9292 if self .start is not None :
@@ -194,7 +194,9 @@ 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 (file : PathType , storage_options : dict [str , str ] | None = None ) -> CSIIndex :
197+ def read_csi (
198+ file : PathType , storage_options : Optional [dict [str , str ]] = None
199+ ) -> CSIIndex :
198200 """Parse a CSI file into a `CSIIndex` object.
199201
200202 Parameters
@@ -309,7 +311,7 @@ def offsets(self) -> Any:
309311
310312
311313def read_tabix (
312- file : PathType , storage_options : dict [str , str ] | None = None
314+ file : PathType , storage_options : Optional [ dict [str , str ]] = None
313315) -> TabixIndex :
314316 """Parse a tabix file into a `TabixIndex` object.
315317
@@ -450,7 +452,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
450452 return False
451453
452454 def contig_record_counts (self ):
453- d = dict (zip (self .sequence_names , self .index .record_counts , strict = True ))
455+ d = dict (zip (self .sequence_names , self .index .record_counts ))
454456 if self .file_type == VcfFileType .BCF :
455457 d = {k : v for k , v in d .items () if v > 0 }
456458 return d
@@ -481,8 +483,8 @@ def _filter_empty_and_refine(self, regions):
481483
482484 def partition_into_regions (
483485 self ,
484- num_parts : int | None = None ,
485- target_part_size : None | int | str = None ,
486+ num_parts : Optional [ int ] = None ,
487+ target_part_size : Union [ None , int , str ] = None ,
486488 ):
487489 if num_parts is None and target_part_size is None :
488490 raise ValueError ("One of num_parts or target_part_size must be specified" )
0 commit comments