|
7 | 7 | import os |
8 | 8 | from array import array |
9 | 9 | from binascii import hexlify, unhexlify |
| 10 | +from collections.abc import ByteString |
10 | 11 | from io import BytesIO, IOBase |
11 | 12 | from mmap import mmap |
12 | 13 | from numbers import Number |
13 | 14 | from pathlib import Path |
14 | 15 | from shutil import copyfile |
15 | 16 | from struct import Struct |
16 | 17 | from textwrap import wrap |
17 | | -from typing import ByteString, Tuple, Union |
| 18 | +from typing import Union |
18 | 19 |
|
19 | 20 | from probables.exceptions import InitializationError, NotSupportedError |
20 | 21 | from probables.hashes import HashFuncT, HashResultsT, KeyT, default_fnv_1a |
@@ -465,7 +466,7 @@ def jaccard_index(self, second: SimpleBloomT) -> Union[float, None]: |
465 | 466 |
|
466 | 467 | # More private functions |
467 | 468 | @classmethod |
468 | | - def _get_optimized_params(cls, estimated_elements: int, false_positive_rate: float) -> Tuple[float, int, int]: |
| 469 | + def _get_optimized_params(cls, estimated_elements: int, false_positive_rate: float) -> tuple[float, int, int]: |
469 | 470 | valid_prms = isinstance(estimated_elements, Number) and estimated_elements > 0 |
470 | 471 | if not valid_prms: |
471 | 472 | msg = "Bloom: estimated elements must be greater than 0" |
@@ -528,15 +529,16 @@ def _load( |
528 | 529 | else: |
529 | 530 | offset = self._FOOTER_STRUCT.size |
530 | 531 | est_els, els_added, fpr, n_hashes, n_bits = self._parse_footer( |
531 | | - self._FOOTER_STRUCT, file[-1 * offset :] # type: ignore |
| 532 | + self._FOOTER_STRUCT, |
| 533 | + file[-1 * offset :], # type: ignore |
532 | 534 | ) |
533 | 535 | self._set_values(est_els, fpr, n_hashes, n_bits, hash_function) |
534 | 536 | # now read in the bit array! |
535 | 537 | self._parse_bloom_array(file, self._IMPT_STRUCT.size * self.bloom_length) # type: ignore |
536 | 538 | self._els_added = els_added |
537 | 539 |
|
538 | 540 | @classmethod |
539 | | - def _parse_footer(cls, stct: Struct, d: ByteString) -> Tuple[int, int, float, int, int]: |
| 541 | + def _parse_footer(cls, stct: Struct, d: ByteString) -> tuple[int, int, float, int, int]: |
540 | 542 | """parse footer returning the data: estimated elements, elements added, |
541 | 543 | false positive rate, hash function, number hashes, number bits""" |
542 | 544 | e_elms, e_added, fpr = stct.unpack_from(bytearray(d)) |
|
0 commit comments