From 280ffa0564b21ad1e6d8240dcfca1aa72ad72394 Mon Sep 17 00:00:00 2001 From: Isidro Arias Date: Thu, 6 Apr 2023 14:17:32 +0200 Subject: [PATCH] type hints requested by boot --- data_structures/hashing/bloom_filter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data_structures/hashing/bloom_filter.py b/data_structures/hashing/bloom_filter.py index 1f08ddaf2..029d24a3e 100644 --- a/data_structures/hashing/bloom_filter.py +++ b/data_structures/hashing/bloom_filter.py @@ -10,7 +10,7 @@ class Bloom: # number of hash functions is fixed HASH_FUNCTIONS = (sha256, md5) - def __init__(self, size=8): + def __init__(self, size: int = 8) -> None: self.bitstring = 0b0 self.size = size @@ -52,7 +52,7 @@ class Bloom: return res -def test_movies(): +def test_movies() -> None: b = Bloom() b.add("Titanic") b.add("Avatar") @@ -66,11 +66,11 @@ def test_movies(): assert b.exists("Pulp Fiction") in (True, False) -def random_string(size): +def random_string(size: int) -> str: return "".join(choices(ascii_lowercase + " ", k=size)) -def test_probability(m=64, n=20): +def test_probability(m: int = 64, n: int = 20) -> None: b = Bloom(size=m) k = len(b.HASH_FUNCTIONS)