[+] partially add check_generic
This commit is contained in:
parent
1e73d19122
commit
bc7ecd5d40
@ -2,7 +2,7 @@
|
||||
# https://gitea.fxreader.online/fxreader.online/freelance-project-34-marketing-blog/issues/2#issue-25
|
||||
|
||||
import typing
|
||||
from typing import Any
|
||||
from typing import Any, TypeVar, Optional, Iterable, Sequence
|
||||
from typing_extensions import Protocol
|
||||
from abc import abstractmethod
|
||||
|
||||
@ -26,3 +26,15 @@ class Comparable(Protocol):
|
||||
|
||||
def __ge__(self: C, other: C) -> bool:
|
||||
return not self < other
|
||||
|
||||
T = TypeVar('T', bound='Iterable[Any] | Sequence[Any]')
|
||||
|
||||
def check_generic(
|
||||
o: Any,
|
||||
t: type[T]
|
||||
) -> T:
|
||||
res = cast(T[Any], o)
|
||||
|
||||
assert isinstance(o, t)
|
||||
|
||||
return res
|
||||
|
Loading…
Reference in New Issue
Block a user