Fixed where query typing

This commit is contained in:
2022-01-15 11:11:14 +01:00
parent 1f445a99b2
commit 62ac976b99
7 changed files with 11 additions and 12 deletions

View File

@@ -15,7 +15,7 @@ __title__ = 'cpl_query.extension'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.11.0.post2'
__version__ = '2021.11.0.post3'
from collections import namedtuple
@@ -27,4 +27,4 @@ from .ordered_iterable_abc import OrderedIterableABC
from .ordered_iterable import OrderedIterable
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='11', micro='0.post2')
version_info = VersionInfo(major='2021', minor='11', micro='0.post3')

View File

@@ -43,7 +43,7 @@ class Iterable(IterableABC):
def count(self, func: Callable = None) -> int:
return count_query(self, func)
def distinct(self, func: Callable) -> IterableABC:
def distinct(self, func: Callable = None) -> IterableABC:
return self.__to_self(distinct_query(self, func))
def element_at(self, index: int) -> any:

View File

@@ -60,9 +60,8 @@ class IterableABC(ABC, list):
__object: :class:`object`
value
"""
if self._type is not None and type(__object) != self._type and not isinstance(type(__object), self._type) \
and not issubclass(type(__object), self._type):
raise Exception(f'Unexpected type: {type(__object)}')
if self._type is not None and type(__object) != self._type and not isinstance(type(__object), self._type) and not issubclass(type(__object), self._type):
raise Exception(f'Unexpected type: {type(__object)}\nExpected type: {self._type}')
if len(self) == 0 and self._type is None:
self._type = type(__object)