From 5a785ad6e6329eec5bd877dcdab4d0f496f7bf60 Mon Sep 17 00:00:00 2001 From: Saksham Chawla <51916697+saksham-chawla@users.noreply.github.com> Date: Wed, 12 Oct 2022 16:54:48 +0530 Subject: [PATCH 1/4] Update hash_table.py --- data_structures/hashing/hash_table.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data_structures/hashing/hash_table.py b/data_structures/hashing/hash_table.py index f4422de53821..d084f6117da3 100644 --- a/data_structures/hashing/hash_table.py +++ b/data_structures/hashing/hash_table.py @@ -1,13 +1,13 @@ #!/usr/bin/env python3 from .number_theory.prime_numbers import next_prime - +from typing import Optional class HashTable: """ Basic Hash Table example with open addressing and linear probing """ - def __init__(self, size_table, charge_factor=None, lim_charge=None): + def __init__(self, size_table: int, charge_factor: Optional[int] = None, lim_charge: Optional[float] = None) -> None: self.size_table = size_table self.values = [None] * self.size_table self.lim_charge = 0.75 if lim_charge is None else lim_charge From 2b70fed38ec698081799bdf16bde291ba575af52 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Oct 2022 11:25:51 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- data_structures/hashing/hash_table.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/data_structures/hashing/hash_table.py b/data_structures/hashing/hash_table.py index d084f6117da3..dc595b377912 100644 --- a/data_structures/hashing/hash_table.py +++ b/data_structures/hashing/hash_table.py @@ -1,13 +1,20 @@ #!/usr/bin/env python3 -from .number_theory.prime_numbers import next_prime from typing import Optional +from .number_theory.prime_numbers import next_prime + + class HashTable: """ Basic Hash Table example with open addressing and linear probing """ - def __init__(self, size_table: int, charge_factor: Optional[int] = None, lim_charge: Optional[float] = None) -> None: + def __init__( + self, + size_table: int, + charge_factor: int | None = None, + lim_charge: float | None = None, + ) -> None: self.size_table = size_table self.values = [None] * self.size_table self.lim_charge = 0.75 if lim_charge is None else lim_charge From e5c57d01f6e8b61b4b9c7d3229ff2bc5ad5a6954 Mon Sep 17 00:00:00 2001 From: Saksham Chawla <51916697+saksham-chawla@users.noreply.github.com> Date: Wed, 12 Oct 2022 16:58:33 +0530 Subject: [PATCH 3/4] Update hash_table.py --- data_structures/hashing/hash_table.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data_structures/hashing/hash_table.py b/data_structures/hashing/hash_table.py index dc595b377912..6bf9da7401d1 100644 --- a/data_structures/hashing/hash_table.py +++ b/data_structures/hashing/hash_table.py @@ -19,8 +19,8 @@ def __init__( self.values = [None] * self.size_table self.lim_charge = 0.75 if lim_charge is None else lim_charge self.charge_factor = 1 if charge_factor is None else charge_factor - self.__aux_list = [] - self._keys = {} + self.__aux_list: list = [] + self._keys: dict = {} def keys(self): return self._keys From 3a41d90cf8ce7ef2a12f43bd5f562aafe654ca1a Mon Sep 17 00:00:00 2001 From: Saksham Chawla <51916697+saksham-chawla@users.noreply.github.com> Date: Wed, 12 Oct 2022 16:59:10 +0530 Subject: [PATCH 4/4] Update hash_table.py --- data_structures/hashing/hash_table.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/data_structures/hashing/hash_table.py b/data_structures/hashing/hash_table.py index 6bf9da7401d1..1cd71cc4baf3 100644 --- a/data_structures/hashing/hash_table.py +++ b/data_structures/hashing/hash_table.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from typing import Optional - from .number_theory.prime_numbers import next_prime