We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1316968 commit ea3b0ceCopy full SHA for ea3b0ce
data_structures/stacks/linked_stack.py
@@ -2,15 +2,15 @@
2
from __future__ import annotations
3
4
from collections.abc import Iterator
5
-from typing import Generic, Optional, TypeVar
+from typing import Generic, TypeVar
6
7
T = TypeVar("T")
8
9
10
class Node(Generic[T]):
11
def __init__(self, data: T):
12
self.data = data
13
- self.next: Optional[Node[T]] = None
+ self.next: Node[T] | None = None
14
15
def __str__(self) -> str:
16
return f"{self.data}"
@@ -47,7 +47,7 @@ class LinkedStack(Generic[T]):
47
"""
48
49
def __init__(self) -> None:
50
- self.top: Optional[Node[T]] = None
+ self.top: Node[T] | None = None
51
52
def __iter__(self) -> Iterator[T]:
53
node = self.top
0 commit comments