diff options
author | 2023-05-09 16:01:01 +0100 | |
---|---|---|
committer | 2023-05-09 16:01:01 +0100 | |
commit | c3e23e60278d34658f801bd7d7ed721d5a272637 (patch) | |
tree | e159a0fae7850d706d713cf2b49dfed2140ce655 /bot/utils/randomization.py | |
parent | Bump sentry-sdk from 1.21.1 to 1.22.1 (#1273) (diff) | |
parent | Move unshared contants inside modules (diff) |
Merge pull request #1270 from python-discord/migrate-to-ruff
Migrate to ruff
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: |