Skip to content

[mypy] Add/fix type annotations for hashes. Fix for binary_tree_traversals #4143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hashes/adler32.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""


def adler32(plain_text: str) -> str:
def adler32(plain_text: str) -> int:
"""
Function implements adler-32 hash.
Itterates and evaluates new value for each character
Expand Down
3 changes: 2 additions & 1 deletion hashes/chaos_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
m = 5

# Buffer Space (with Parameters Space)
buffer_space, params_space = [], []
buffer_space: list[int] = []
params_space: list[int] = []

# Machine Time
machine_time = 0
Expand Down
4 changes: 2 additions & 2 deletions hashes/md5.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def rearrange(bitString32):
return newString


def reformatHex(i):
def reformatHex(i: int) -> str:
"""[summary]
Converts the given integer into 8-digit hex number.

Expand Down Expand Up @@ -81,7 +81,7 @@ def getBlock(bitString):
currPos += 512


def not32(i):
def not32(i: int) -> int:
"""
>>> not32(34)
4294967261
Expand Down
2 changes: 1 addition & 1 deletion hashes/sdbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""


def sdbm(plain_text: str) -> str:
def sdbm(plain_text: str) -> int:
"""
Function implements sdbm hash, easy to use, great for bits scrambling.
iterates over each character in the given string and applies function to each of
Expand Down
4 changes: 2 additions & 2 deletions traversals/binary_tree_traversals.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def pre_order_iter(node: TreeNode) -> None:
"""
if not isinstance(node, TreeNode) or not node:
return
stack: List[TreeNode] = []
stack: list[TreeNode] = []
n = node
while n or stack:
while n: # start from root node, find its left child
Expand Down Expand Up @@ -218,7 +218,7 @@ def in_order_iter(node: TreeNode) -> None:
"""
if not isinstance(node, TreeNode) or not node:
return
stack: List[TreeNode] = []
stack: list[TreeNode] = []
n = node
while n or stack:
while n:
Expand Down