Skip to content

[mypy] Fix type annotations for double ended queue in data structures #5549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more readable syntax
  • Loading branch information
dylanbuchi committed Oct 23, 2021
commit 6dbc9d085d6bf5e6c4f4b5713627d68d7a96c56e
10 changes: 6 additions & 4 deletions data_structures/queue/linked_queue.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
""" A Queue using a linked list like structure """
from typing import Any, Iterator, Optional
from __future__ import annotations

from typing import Any, Iterator


class Node:
def __init__(self, data: Any) -> None:
self.data: Any = data
self.next: Optional[Node] = None
self.next: Node | None = None

def __str__(self) -> str:
return f"{self.data}"
Expand Down Expand Up @@ -39,8 +41,8 @@ class LinkedQueue:
"""

def __init__(self) -> None:
self.front: Optional[Node] = None
self.rear: Optional[Node] = None
self.front: Node | None = None
self.rear: Node | None = None

def __iter__(self) -> Iterator[Any]:
node = self.front
Expand Down