Fixed type problems with ordered List

This commit is contained in:
Sven Heidemann 2021-11-22 20:52:10 +01:00
parent 40876005d5
commit 5d0444bcc0
4 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@ from cpl_query.extension.ordered_iterable_abc import OrderedIterableABC
def order_by_query(_list: IterableABC, _func: Callable) -> OrderedIterableABC:
result = OrderedIterableABC(_func)
result = OrderedIterableABC(_list.type, _func)
_list.sort(key=_func)
result.extend(_list)
return result
@ -19,7 +19,7 @@ def order_by_descending_query(_list: IterableABC, _func: Callable) -> OrderedIte
if _func is None:
raise ArgumentNoneException(ExceptionArgument.func)
result = OrderedIterableABC(_func)
result = OrderedIterableABC(_list.type, _func)
_list.sort(key=_func, reverse=True)
result.extend(_list)
return result

View File

@ -75,13 +75,13 @@ class Iterable(IterableABC):
def order_by(self, func: Callable) -> OrderedIterableABC:
res = order_by_query(self, func)
from cpl_query._extension.ordered_iterable import OrderedIterable
from cpl_query.extension.ordered_iterable import OrderedIterable
res.__class__ = OrderedIterable
return res
def order_by_descending(self, func: Callable) -> OrderedIterableABC:
res = order_by_descending_query(self, func)
from cpl_query._extension.ordered_iterable import OrderedIterable
from cpl_query.extension.ordered_iterable import OrderedIterable
res.__class__ = OrderedIterable
return res

View File

@ -9,9 +9,9 @@ class OrderedIterable(Iterable, OrderedIterableABC):
r"""Implementation of :class: `cpl_query.extension.Iterable` `cpl_query.extension.OrderedIterableABC`
"""
def __init__(self):
Iterable.__init__(self)
OrderedIterableABC.__init__(self)
def __init__(self, _t: type = None):
Iterable.__init__(self, _t)
OrderedIterableABC.__init__(self, _t)
def then_by(self, _func: Callable) -> OrderedIterableABC:
self._funcs.append(_func)

View File

@ -7,8 +7,8 @@ from cpl_query.extension.iterable_abc import IterableABC
class OrderedIterableABC(IterableABC):
@abstractmethod
def __init__(self, _func: Callable = None):
IterableABC.__init__(self)
def __init__(self, _t: type, _func: Callable = None):
IterableABC.__init__(self, _t)
self._funcs: list[Callable] = []
if _func is not None:
self._funcs.append(_func)