7
7
from collections .abc import Sequence
8
8
from dataclasses import dataclass
9
9
from enum import Enum
10
- from typing import IO , Any , Optional , Union
10
+ from typing import IO , Any
11
11
12
12
import cyvcf2
13
13
import humanfriendly
@@ -33,7 +33,7 @@ def get_file_offset(vfp: int) -> int:
33
33
return vfp >> 16 & address_mask
34
34
35
35
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 :
37
37
"""Read bytes using a `struct` format string and return the unpacked data value.
38
38
39
39
Parameters
@@ -85,8 +85,8 @@ class Region:
85
85
"""
86
86
87
87
contig : str
88
- start : Optional [ int ] = None
89
- end : Optional [ int ] = None
88
+ start : int | None = None
89
+ end : int | None = None
90
90
91
91
def __post_init__ (self ):
92
92
assert self .contig is not None
@@ -197,9 +197,7 @@ def get_first_locus_in_bin(csi: CSIIndex, bin: int) -> int:
197
197
return (bin - first_bin_on_level ) * (max_span // level_size ) + 1
198
198
199
199
200
- def read_csi (
201
- file : PathType , storage_options : Optional [dict [str , str ]] = None
202
- ) -> CSIIndex :
200
+ def read_csi (file : PathType , storage_options : dict [str , str ] | None = None ) -> CSIIndex :
203
201
"""Parse a CSI file into a `CSIIndex` object.
204
202
205
203
Parameters
@@ -314,7 +312,7 @@ def offsets(self) -> Any:
314
312
315
313
316
314
def read_tabix (
317
- file : PathType , storage_options : Optional [ dict [str , str ]] = None
315
+ file : PathType , storage_options : dict [str , str ] | None = None
318
316
) -> TabixIndex :
319
317
"""Parse a tabix file into a `TabixIndex` object.
320
318
@@ -512,8 +510,8 @@ def _filter_empty_and_refine(self, regions):
512
510
513
511
def partition_into_regions (
514
512
self ,
515
- num_parts : Optional [ int ] = None ,
516
- target_part_size : Union [ None , int , str ] = None ,
513
+ num_parts : int | None = None ,
514
+ target_part_size : None | int | str = None ,
517
515
):
518
516
if num_parts is None and target_part_size is None :
519
517
raise ValueError ("One of num_parts or target_part_size must be specified" )
0 commit comments