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