Skip to content

Commit b9e8833

Browse files
authored
Drop py38 (#132)
1 parent 5b0cd94 commit b9e8833

12 files changed

Lines changed: 138 additions & 46 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
14+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1515

1616
steps:
1717
- uses: actions/checkout@v4

probables/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
ExpandingBloomFilter,
1010
RotatingBloomFilter,
1111
)
12-
from probables.countminsketch import CountMeanMinSketch, CountMeanSketch, CountMinSketch, HeavyHitters, StreamThreshold
12+
from probables.countminsketch import (
13+
CountMeanMinSketch,
14+
CountMeanSketch,
15+
CountMinSketch,
16+
HeavyHitters,
17+
StreamThreshold,
18+
)
1319
from probables.cuckoo import CountingCuckooFilter, CuckooFilter
1420
from probables.exceptions import (
1521
CuckooFilterFullError,
@@ -26,7 +32,7 @@
2632
__email__ = "barrust@gmail.com"
2733
__license__ = "MIT"
2834
__version__ = "0.6.1"
29-
__credits__: List[str] = []
35+
__credits__: list[str] = []
3036
__url__ = "https://github.com/barrust/pyprobables"
3137
__bugtrack_url__ = "https://github.com/barrust/pyprobables/issues"
3238

probables/blooms/bloom.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import os
88
from array import array
99
from binascii import hexlify, unhexlify
10+
from collections.abc import ByteString
1011
from io import BytesIO, IOBase
1112
from mmap import mmap
1213
from numbers import Number
1314
from pathlib import Path
1415
from shutil import copyfile
1516
from struct import Struct
1617
from textwrap import wrap
17-
from typing import ByteString, Tuple, Union
18+
from typing import Union
1819

1920
from probables.exceptions import InitializationError, NotSupportedError
2021
from probables.hashes import HashFuncT, HashResultsT, KeyT, default_fnv_1a
@@ -465,7 +466,7 @@ def jaccard_index(self, second: SimpleBloomT) -> Union[float, None]:
465466

466467
# More private functions
467468
@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]:
469470
valid_prms = isinstance(estimated_elements, Number) and estimated_elements > 0
470471
if not valid_prms:
471472
msg = "Bloom: estimated elements must be greater than 0"
@@ -528,15 +529,16 @@ def _load(
528529
else:
529530
offset = self._FOOTER_STRUCT.size
530531
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
532534
)
533535
self._set_values(est_els, fpr, n_hashes, n_bits, hash_function)
534536
# now read in the bit array!
535537
self._parse_bloom_array(file, self._IMPT_STRUCT.size * self.bloom_length) # type: ignore
536538
self._els_added = els_added
537539

538540
@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]:
540542
"""parse footer returning the data: estimated elements, elements added,
541543
false positive rate, hash function, number hashes, number bits"""
542544
e_elms, e_added, fpr = stct.unpack_from(bytearray(d))

probables/blooms/countingbloom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
URL: https://github.com/barrust/counting_bloom
55
"""
66
from array import array
7+
from collections.abc import ByteString
78
from pathlib import Path
89
from struct import Struct
9-
from typing import ByteString, Union
10+
from typing import Union
1011

1112
from probables.blooms.bloom import BloomFilter
1213
from probables.constants import UINT32_T_MAX, UINT64_T_MAX

probables/blooms/expandingbloom.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"""
66

77
from array import array
8+
from collections.abc import ByteString
89
from io import BytesIO, IOBase
910
from mmap import mmap
1011
from pathlib import Path
1112
from struct import Struct
12-
from typing import ByteString, Tuple, Union
13+
from typing import Union
1314

1415
from probables.blooms.bloom import BloomFilter
1516
from probables.exceptions import RotatingBloomFilterError
@@ -224,7 +225,7 @@ def __load(self, file: Union[Path, str, IOBase, mmap]):
224225
self._parse_blooms(file, size) # type:ignore
225226

226227
@classmethod
227-
def _parse_footer(cls, b: ByteString) -> Tuple[int, int, int, float]:
228+
def _parse_footer(cls, b: ByteString) -> tuple[int, int, int, float]:
228229
offset = cls.__FOOTER_STRUCT.size
229230
size, est_els, els_added, fpr = cls.__FOOTER_STRUCT.unpack(bytes(b[-1 * offset :]))
230231
return int(size), int(est_els), int(els_added), float(fpr)

probables/countminsketch/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,4 @@
88
StreamThreshold,
99
)
1010

11-
__all__ = [
12-
"CountMinSketch",
13-
"HeavyHitters",
14-
"StreamThreshold",
15-
"CountMeanSketch",
16-
"CountMeanMinSketch",
17-
]
11+
__all__ = ["CountMinSketch", "HeavyHitters", "StreamThreshold", "CountMeanSketch", "CountMeanMinSketch"]

probables/countminsketch/countminsketch.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
import math
88
from array import array
9+
from collections.abc import ByteString
910
from io import BytesIO, IOBase
1011
from mmap import mmap
1112
from numbers import Number
1213
from pathlib import Path
1314
from struct import Struct
14-
from typing import ByteString, Dict, Tuple, Union
15+
from typing import Union
1516

1617
from probables.constants import INT32_T_MAX, INT32_T_MIN, INT64_T_MAX, INT64_T_MIN
1718
from probables.exceptions import CountMinSketchError, InitializationError, NotSupportedError
@@ -408,7 +409,7 @@ def __load(self, file: Union[Path, str, IOBase, mmap]):
408409
self._parse_bytes(file) # type: ignore
409410

410411
@classmethod
411-
def _parse_footer(cls, file: ByteString) -> Tuple[int, int, int]:
412+
def _parse_footer(cls, file: ByteString) -> tuple[int, int, int]:
412413
"""return width, depth and elements added, in that order"""
413414
offset = cls.__FOOTER_STRUCT.size
414415
width, depth, elements_added = cls.__FOOTER_STRUCT.unpack_from(bytes(file[-1 * offset :]))
@@ -599,7 +600,7 @@ def __str__(self) -> str:
599600
)
600601

601602
@property
602-
def heavy_hitters(self) -> Dict[str, int]:
603+
def heavy_hitters(self) -> dict[str, int]:
603604
"""dict: Return the heavy hitters, or most common elements
604605
605606
Note:
@@ -758,7 +759,7 @@ def __str__(self) -> str:
758759
)
759760

760761
@property
761-
def meets_threshold(self) -> Dict[str, int]:
762+
def meets_threshold(self) -> dict[str, int]:
762763
"""dict: Those keys that meet the required threshold (with value)"""
763764
return self.__meets_threshold
764765

probables/cuckoo/countingcuckoo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
import random
77
from array import array
8+
from collections.abc import ByteString
89
from io import IOBase
910
from mmap import mmap
1011
from pathlib import Path
1112
from struct import Struct
12-
from typing import ByteString, List, Union
13+
from typing import Union
1314

1415
from probables.cuckoo.cuckoo import CuckooFilter
1516
from probables.exceptions import CuckooFilterFullError
@@ -145,7 +146,7 @@ def unique_elements(self) -> int:
145146
return self.__unique_elements
146147

147148
@property
148-
def buckets(self) -> List[List["CountingCuckooBin"]]: # type: ignore
149+
def buckets(self) -> list[list["CountingCuckooBin"]]: # type: ignore
149150
"""list(list): The buckets holding the fingerprints
150151
151152
Note:

probables/cuckoo/cuckoo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
import math
77
import random
88
from array import array
9+
from collections.abc import ByteString
910
from io import BytesIO, IOBase
1011
from mmap import mmap
1112
from numbers import Number
1213
from pathlib import Path
1314
from struct import Struct
14-
from typing import ByteString, List, Tuple, Union
15+
from typing import Union
1516

1617
from probables.exceptions import CuckooFilterFullError, InitializationError
1718
from probables.hashes import KeyT, SimpleHashT, fnv_1a
@@ -226,7 +227,7 @@ def bucket_size(self) -> int:
226227
return self._bucket_size
227228

228229
@property
229-
def buckets(self) -> List[List[int]]:
230+
def buckets(self) -> list[list[int]]:
230231
"""list(list): The buckets holding the fingerprints
231232
232233
Note:
@@ -491,7 +492,7 @@ def _indicies_from_fingerprint(self, fingerprint):
491492
idx_2 = self.__hash_func(str(fingerprint)) % self.capacity
492493
return idx_1, idx_2
493494

494-
def _generate_fingerprint_info(self, key: KeyT) -> Tuple[int, int, int]:
495+
def _generate_fingerprint_info(self, key: KeyT) -> tuple[int, int, int]:
495496
"""Generate the fingerprint and indicies using the provided key
496497
497498
Args:

probables/hashes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from functools import wraps
44
from hashlib import md5, sha256
55
from struct import unpack
6-
from typing import Callable, List, Union
6+
from typing import Callable, Union
77

88
from probables.constants import UINT32_T_MAX, UINT64_T_MAX
99

1010
KeyT = Union[str, bytes]
1111
SimpleHashT = Callable[[KeyT, int], int]
12-
HashResultsT = List[int]
12+
HashResultsT = list[int]
1313
HashFuncT = Callable[[KeyT, int], HashResultsT]
1414
HashFuncBytesT = Callable[[KeyT, int], bytes]
1515

@@ -67,7 +67,7 @@ def hashing_func(key, depth=1):
6767
return hashing_func
6868

6969

70-
def default_fnv_1a(key: KeyT, depth: int = 1) -> List[int]:
70+
def default_fnv_1a(key: KeyT, depth: int = 1) -> list[int]:
7171
"""The default fnv-1a hashing routine
7272
7373
Args:

0 commit comments

Comments
 (0)