mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-19 02:38:12 +08:00
[mypy] Fix type annotations for linked_stack.py, evaluate_postfix_notations.py, stack.py in data structures (#4409)
* [mypy] Fix type annotations for linked_stack.py, next_greater_element.py, stack.py * Reformatted files according to black
This commit is contained in:

committed by
GitHub

parent
727341e3db
commit
deb71167e7
@ -1,5 +1,5 @@
|
||||
""" A Stack using a linked list like structure """
|
||||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
|
||||
|
||||
class Node:
|
||||
@ -42,7 +42,7 @@ class LinkedStack:
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.top = None
|
||||
self.top: Optional[Node] = None
|
||||
|
||||
def __iter__(self):
|
||||
node = self.top
|
||||
@ -134,6 +134,8 @@ class LinkedStack:
|
||||
"""
|
||||
if self.is_empty():
|
||||
raise IndexError("peek from empty stack")
|
||||
|
||||
assert self.top is not None
|
||||
return self.top.data
|
||||
|
||||
def clear(self) -> None:
|
||||
|
Reference in New Issue
Block a user