From af50521c1cc05334550a3e5806f9e6c8705c38bc Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 8 Aug 2024 14:36:08 +0300 Subject: [PATCH] typing --- cantok/tokens/abstract/abstract_token.py | 6 +++--- cantok/tokens/timeout_token.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cantok/tokens/abstract/abstract_token.py b/cantok/tokens/abstract/abstract_token.py index 4dfd361..7d5c951 100644 --- a/cantok/tokens/abstract/abstract_token.py +++ b/cantok/tokens/abstract/abstract_token.py @@ -2,7 +2,7 @@ from abc import ABC, abstractmethod from threading import RLock from typing import Tuple, List, Dict, Awaitable, Optional, Union, Any - +from collections.abc import Iterable from cantok.errors import CancellationError from cantok.tokens.abstract.cancel_cause import CancelCause @@ -79,9 +79,9 @@ def __add__(self, item: 'AbstractToken') -> 'AbstractToken': def __bool__(self) -> bool: return self.keep_on() - def filter_tokens(self, tokens: Tuple['AbstractToken', ...]) -> List['AbstractToken']: + def filter_tokens(self, tokens: Iterable['AbstractToken']) -> List['AbstractToken']: from cantok import DefaultToken - + result: List[AbstractToken] = [] for token in tokens: diff --git a/cantok/tokens/timeout_token.py b/cantok/tokens/timeout_token.py index 18280be..ca9252c 100644 --- a/cantok/tokens/timeout_token.py +++ b/cantok/tokens/timeout_token.py @@ -1,6 +1,6 @@ from time import monotonic_ns, perf_counter - from typing import Union, Callable, Tuple, List, Dict, Any +from collections.abc import Iterable from cantok import AbstractToken from cantok import ConditionToken @@ -33,7 +33,7 @@ def function() -> bool: super().__init__(function, *tokens, cancelled=cancelled) - def filter_tokens(self, tokens: Tuple['AbstractToken', ...]) -> List['AbstractToken']: + def filter_tokens(self, tokens: Iterable[AbstractToken]) -> List[AbstractToken]: result: List[AbstractToken] = [] for token in tokens: