From ceff0074472531a2bac5373d26ec168203e5b4c5 Mon Sep 17 00:00:00 2001 From: Saksham Chawla <51916697+saksham-chawla@users.noreply.github.com> Date: Wed, 12 Oct 2022 16:30:52 +0530 Subject: [PATCH 1/2] Add typing hacktoberfest --- data_structures/queue/queue_on_pseudo_stack.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data_structures/queue/queue_on_pseudo_stack.py b/data_structures/queue/queue_on_pseudo_stack.py index 7fa2fb2566af..1d68957ea128 100644 --- a/data_structures/queue/queue_on_pseudo_stack.py +++ b/data_structures/queue/queue_on_pseudo_stack.py @@ -1,5 +1,5 @@ """Queue represented by a pseudo stack (represented by a list with pop and append)""" - +from typing import Any class Queue: def __init__(self): @@ -14,7 +14,7 @@ def __str__(self): @param item item to enqueue""" - def put(self, item): + def put(self, item: Any) -> None: self.stack.append(item) self.length = self.length + 1 @@ -23,7 +23,7 @@ def put(self, item): @return dequeued item that was dequeued""" - def get(self): + def get(self) -> Any: self.rotate(1) dequeued = self.stack[self.length - 1] self.stack = self.stack[:-1] @@ -35,7 +35,7 @@ def get(self): @param rotation number of times to rotate queue""" - def rotate(self, rotation): + def rotate(self, rotation: int) -> None: for i in range(rotation): temp = self.stack[0] self.stack = self.stack[1:] @@ -45,7 +45,7 @@ def rotate(self, rotation): """Reports item at the front of self @return item at front of self.stack""" - def front(self): + def front(self) -> Any: front = self.get() self.put(front) self.rotate(self.length - 1) @@ -53,5 +53,5 @@ def front(self): """Returns the length of this.stack""" - def size(self): + def size(self) -> int: return self.length From dfccc761e37826d34e1856725337676548237b15 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Oct 2022 11:03:12 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- data_structures/queue/queue_on_pseudo_stack.py | 1 + 1 file changed, 1 insertion(+) diff --git a/data_structures/queue/queue_on_pseudo_stack.py b/data_structures/queue/queue_on_pseudo_stack.py index 1d68957ea128..9a0c16f61eb4 100644 --- a/data_structures/queue/queue_on_pseudo_stack.py +++ b/data_structures/queue/queue_on_pseudo_stack.py @@ -1,6 +1,7 @@ """Queue represented by a pseudo stack (represented by a list with pop and append)""" from typing import Any + class Queue: def __init__(self): self.stack = []