Fix type annotations for stack.py (#5566) · zinating/algorithms-python@c0ed031 · GitHub
Skip to content

Commit c0ed031

Browse files
authored
Fix type annotations for stack.py (TheAlgorithms#5566)
1 parent 582f57f commit c0ed031

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

data_structures/stacks/balanced_parentheses.py

Lines changed: 1 addition & 1 deletion

data_structures/stacks/dijkstras_two_stack_algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def dijkstras_two_stack_algorithm(equation: str) -> int:
5151
"""
5252
operators = {"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub}
5353

54-
operand_stack = Stack()
55-
operator_stack = Stack()
54+
operand_stack: Stack[int] = Stack()
55+
operator_stack: Stack[str] = Stack()
5656

5757
for i in equation:
5858
if i.isdigit():

data_structures/stacks/infix_to_postfix_conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def infix_to_postfix(expression_str: str) -> str:
3838
"""
3939
if not balanced_parentheses(expression_str):
4040
raise ValueError("Mismatched parentheses")
41-
stack = Stack()
41+
stack: Stack[str] = Stack()
4242
postfix = []
4343
for char in expression_str:
4444
if char.isalpha() or char.isdigit():

data_structures/stacks/stack.py

Lines changed: 11 additions & 7 deletions

0 commit comments

Comments
 (0)