Fixed type problems with ordered List
This commit is contained in:
parent
40876005d5
commit
5d0444bcc0
@ -6,7 +6,7 @@ from cpl_query.extension.ordered_iterable_abc import OrderedIterableABC
|
|||||||
|
|
||||||
|
|
||||||
def order_by_query(_list: IterableABC, _func: Callable) -> OrderedIterableABC:
|
def order_by_query(_list: IterableABC, _func: Callable) -> OrderedIterableABC:
|
||||||
result = OrderedIterableABC(_func)
|
result = OrderedIterableABC(_list.type, _func)
|
||||||
_list.sort(key=_func)
|
_list.sort(key=_func)
|
||||||
result.extend(_list)
|
result.extend(_list)
|
||||||
return result
|
return result
|
||||||
@ -19,7 +19,7 @@ def order_by_descending_query(_list: IterableABC, _func: Callable) -> OrderedIte
|
|||||||
if _func is None:
|
if _func is None:
|
||||||
raise ArgumentNoneException(ExceptionArgument.func)
|
raise ArgumentNoneException(ExceptionArgument.func)
|
||||||
|
|
||||||
result = OrderedIterableABC(_func)
|
result = OrderedIterableABC(_list.type, _func)
|
||||||
_list.sort(key=_func, reverse=True)
|
_list.sort(key=_func, reverse=True)
|
||||||
result.extend(_list)
|
result.extend(_list)
|
||||||
return result
|
return result
|
||||||
|
@ -75,13 +75,13 @@ class Iterable(IterableABC):
|
|||||||
|
|
||||||
def order_by(self, func: Callable) -> OrderedIterableABC:
|
def order_by(self, func: Callable) -> OrderedIterableABC:
|
||||||
res = order_by_query(self, func)
|
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
|
res.__class__ = OrderedIterable
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def order_by_descending(self, func: Callable) -> OrderedIterableABC:
|
def order_by_descending(self, func: Callable) -> OrderedIterableABC:
|
||||||
res = order_by_descending_query(self, func)
|
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
|
res.__class__ = OrderedIterable
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ class OrderedIterable(Iterable, OrderedIterableABC):
|
|||||||
r"""Implementation of :class: `cpl_query.extension.Iterable` `cpl_query.extension.OrderedIterableABC`
|
r"""Implementation of :class: `cpl_query.extension.Iterable` `cpl_query.extension.OrderedIterableABC`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, _t: type = None):
|
||||||
Iterable.__init__(self)
|
Iterable.__init__(self, _t)
|
||||||
OrderedIterableABC.__init__(self)
|
OrderedIterableABC.__init__(self, _t)
|
||||||
|
|
||||||
def then_by(self, _func: Callable) -> OrderedIterableABC:
|
def then_by(self, _func: Callable) -> OrderedIterableABC:
|
||||||
self._funcs.append(_func)
|
self._funcs.append(_func)
|
||||||
|
@ -7,8 +7,8 @@ from cpl_query.extension.iterable_abc import IterableABC
|
|||||||
class OrderedIterableABC(IterableABC):
|
class OrderedIterableABC(IterableABC):
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def __init__(self, _func: Callable = None):
|
def __init__(self, _t: type, _func: Callable = None):
|
||||||
IterableABC.__init__(self)
|
IterableABC.__init__(self, _t)
|
||||||
self._funcs: list[Callable] = []
|
self._funcs: list[Callable] = []
|
||||||
if _func is not None:
|
if _func is not None:
|
||||||
self._funcs.append(_func)
|
self._funcs.append(_func)
|
||||||
|
Loading…
Reference in New Issue
Block a user