mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-08 12:35:59 +08:00
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
from typing import Any, List
|
||||
|
||||
"""
|
||||
The Reverse Polish Nation also known as Polish postfix notation
|
||||
or simply postfix notation.
|
||||
@ -8,6 +6,9 @@ Classic examples of simple stack implementations
|
||||
Valid operators are +, -, *, /.
|
||||
Each operand may be an integer or another expression.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def evaluate_postfix(postfix_notation: list) -> int:
|
||||
@ -23,7 +24,7 @@ def evaluate_postfix(postfix_notation: list) -> int:
|
||||
return 0
|
||||
|
||||
operations = {"+", "-", "*", "/"}
|
||||
stack: List[Any] = []
|
||||
stack: list[Any] = []
|
||||
|
||||
for token in postfix_notation:
|
||||
if token in operations:
|
||||
|
@ -1,5 +1,7 @@
|
||||
""" A Stack using a linked list like structure """
|
||||
from typing import Any, Optional
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Node:
|
||||
@ -42,7 +44,7 @@ class LinkedStack:
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.top: Optional[Node] = None
|
||||
self.top: Node | None = None
|
||||
|
||||
def __iter__(self):
|
||||
node = self.top
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import List
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
class StackOverflowError(BaseException):
|
||||
@ -15,7 +15,7 @@ class Stack:
|
||||
"""
|
||||
|
||||
def __init__(self, limit: int = 10):
|
||||
self.stack: List[int] = []
|
||||
self.stack: list[int] = []
|
||||
self.limit = limit
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
|
Reference in New Issue
Block a user