diff options
author | 2023-05-17 12:23:29 +0530 | |
---|---|---|
committer | 2023-05-17 12:23:29 +0530 | |
commit | 7876744fedab9fbb22a160c8950ee22262570270 (patch) | |
tree | f7189b5f3e9c0947d71f86461f151e50092f6e2c /bot/utils/randomization.py | |
parent | nit (diff) | |
parent | Bump sentry-sdk from 1.22.2 to 1.23.0 (#1277) (diff) |
Merge branch 'main' into undeprecate-bookmark
Diffstat (limited to 'bot/utils/randomization.py')
-rw-r--r-- | bot/utils/randomization.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bot/utils/randomization.py b/bot/utils/randomization.py index c9eabbd2..1caff3fa 100644 --- a/bot/utils/randomization.py +++ b/bot/utils/randomization.py @@ -1,7 +1,9 @@ import itertools import random from collections.abc import Iterable -from typing import Any +from typing import TypeVar + +T = TypeVar("T") class RandomCycle: @@ -11,11 +13,11 @@ class RandomCycle: The iterable is reshuffled after each full cycle. """ - def __init__(self, iterable: Iterable): + def __init__(self, iterable: Iterable[T]): self.iterable = list(iterable) self.index = itertools.cycle(range(len(iterable))) - def __next__(self) -> Any: + def __next__(self) -> T: idx = next(self.index) if idx == 0: |