mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-22 05:16:39 +08:00
Various ruff fixes (#12821)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Generic, TypeVar
|
||||
from typing import TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
@ -13,7 +13,7 @@ class StackUnderflowError(BaseException):
|
||||
pass
|
||||
|
||||
|
||||
class Stack(Generic[T]):
|
||||
class Stack[T]:
|
||||
"""A stack is an abstract data type that serves as a collection of
|
||||
elements with two principal operations: push() and pop(). push() adds an
|
||||
element to the top of the stack, and pop() removes an element from the top
|
||||
|
@ -3,19 +3,19 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Generic, TypeVar
|
||||
from typing import TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class Node(Generic[T]):
|
||||
class Node[T]:
|
||||
def __init__(self, data: T):
|
||||
self.data = data # Assign data
|
||||
self.next: Node[T] | None = None # Initialize next as null
|
||||
self.prev: Node[T] | None = None # Initialize prev as null
|
||||
|
||||
|
||||
class Stack(Generic[T]):
|
||||
class Stack[T]:
|
||||
"""
|
||||
>>> stack = Stack()
|
||||
>>> stack.is_empty()
|
||||
|
@ -3,12 +3,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterator
|
||||
from typing import Generic, TypeVar
|
||||
from typing import TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class Node(Generic[T]):
|
||||
class Node[T]:
|
||||
def __init__(self, data: T):
|
||||
self.data = data
|
||||
self.next: Node[T] | None = None
|
||||
@ -17,7 +17,7 @@ class Node(Generic[T]):
|
||||
return f"{self.data}"
|
||||
|
||||
|
||||
class LinkedStack(Generic[T]):
|
||||
class LinkedStack[T]:
|
||||
"""
|
||||
Linked List Stack implementing push (to top),
|
||||
pop (from top) and is_empty
|
||||
|
Reference in New Issue
Block a user