Skip to content

Commit

Permalink
Update to use python 3.12 syntax for generics
Browse files Browse the repository at this point in the history
  • Loading branch information
ABDreos committed Feb 21, 2024
1 parent 08d2253 commit d7f22df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
5 changes: 2 additions & 3 deletions 2024/tuesday_tips/generics/stack.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Optional, TypeVar, Generic
from typing import Optional

T = TypeVar('T')

class Stack(Generic[T]):
class Stack[T]:
def __init__(self) -> None:
self._container: list[T] = []

Expand Down
5 changes: 1 addition & 4 deletions 2024/tuesday_tips/generics/vector_stack.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from typing import TypeVar
from stack import Stack

T = TypeVar('T', int, float)


class VectorStack(Stack[T]):
class VectorStack[T: (int, float)](Stack[T]):
def __getitem__(self, index: int) -> T:
return self._container[index]

Expand Down

0 comments on commit d7f22df

Please sign in to comment.