Changed func type from str to Callable

This commit is contained in:
2021-07-26 15:32:28 +02:00
parent 0cae3428b9
commit b7be439381
5 changed files with 32 additions and 26 deletions

View File

@@ -16,7 +16,7 @@ class Iterable(IterableABC):
def __init__(self):
IterableABC.__init__(self)
def any(self, func: str) -> bool:
def any(self, func: Callable) -> bool:
return any_query(self, func)
def first(self) -> any:
@@ -44,7 +44,7 @@ class Iterable(IterableABC):
def single_or_default(self) -> Optional[any]:
return single_or_default_query(self)
def where(self, func: str) -> IterableABC:
def where(self, func: Callable) -> IterableABC:
res = where_query(self, func)
res.__class__ = Iterable
return res

View File

@@ -9,7 +9,7 @@ class IterableABC(ABC, list):
list.__init__(self)
@abstractmethod
def any(self, func: str) -> bool: pass
def any(self, func: Callable) -> bool: pass
@abstractmethod
def first(self) -> any: pass
@@ -33,4 +33,4 @@ class IterableABC(ABC, list):
def single_or_default(self) -> Optional[any]: pass
@abstractmethod
def where(self, func: str) -> 'IterableABC': pass
def where(self, func: Callable) -> 'IterableABC': pass