Skip to content

Commit ea3b0ce

Browse files
committed
Replace Optional with inline union type
1 parent 1316968 commit ea3b0ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

data_structures/stacks/linked_stack.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
from __future__ import annotations
33

44
from collections.abc import Iterator
5-
from typing import Generic, Optional, TypeVar
5+
from typing import Generic, TypeVar
66

77
T = TypeVar("T")
88

99

1010
class Node(Generic[T]):
1111
def __init__(self, data: T):
1212
self.data = data
13-
self.next: Optional[Node[T]] = None
13+
self.next: Node[T] | None = None
1414

1515
def __str__(self) -> str:
1616
return f"{self.data}"
@@ -47,7 +47,7 @@ class LinkedStack(Generic[T]):
4747
"""
4848

4949
def __init__(self) -> None:
50-
self.top: Optional[Node[T]] = None
50+
self.top: Node[T] | None = None
5151

5252
def __iter__(self) -> Iterator[T]:
5353
node = self.top

0 commit comments

Comments
 (0)