Skip to content

Commit 392dee4

Browse files
committed
type error fixed
1 parent 71e65c0 commit 392dee4

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
build:
1414

15-
runs-on: ubuntu-latest
15+
runs-on: windows-latest
1616
strategy:
1717
fail-fast: false
1818
matrix:

filexdb/collection.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __find_one(self, query: Mapping = None) -> Document | None:
133133
return _result
134134
"""
135135

136-
def find(self, query: Mapping = None, limit: tuple = None) -> List[Document | None]:
136+
def find(self, query=None, limit=None) -> List[Document]:
137137
"""
138138
Finds all ``Document`` of ``Collection``.
139139
@@ -155,7 +155,7 @@ def find(self, query: Mapping = None, limit: tuple = None) -> List[Document | No
155155
# if limit, Check everything ok
156156
_limit_start = _limit_end = None
157157

158-
if limit:
158+
if limit and type(limit) == type((1, 3)):
159159
if len(limit) == 2:
160160

161161
_limit_start = limit[0]
@@ -175,15 +175,16 @@ def find(self, query: Mapping = None, limit: tuple = None) -> List[Document | No
175175

176176
# check if lower limit is valid or not
177177
if _limit_start >= len(self._collection):
178-
raise ValueError(f"Lower limit should be smaller than Collection length.\n It must be less than `{len(self._collection)}`. `{_limit_start}` is given.")
178+
raise ValueError(
179+
f"Lower limit should be smaller than Collection length.\n It must be less than `{len(self._collection)}`. `{_limit_start}` is given.")
179180
else:
180181
_result = self._collection[_limit_start: _limit_end]
181182
else:
182183
_result = self._collection
183184

184185
return _result
185186

186-
elif query is not None:
187+
elif query is not None and type(query) == type({}):
187188
if limit:
188189
for i in self._collection:
189190
_doc = self._find_document_by_query(query)
@@ -212,8 +213,12 @@ def find(self, query: Mapping = None, limit: tuple = None) -> List[Document | No
212213

213214
if _doc:
214215
_result += _doc
216+
else:
217+
_result = _result
215218
self._reset_cursor()
216219

220+
221+
217222
return _result
218223

219224
def delete(self, query: Mapping = None) -> List[str]:
@@ -277,7 +282,6 @@ def update(self, document: Mapping, query: Mapping = None) -> List[str]:
277282

278283
return _doc_id
279284

280-
281285
def count(self, query: Mapping = None, limit: tuple = None) -> int:
282286
"""
283287
Return amount of Document found.
@@ -297,7 +301,7 @@ def _reset_cursor(self) -> None:
297301
"""
298302
self._cursor = 0
299303

300-
def _find_document_by_query(self, query: Mapping) -> List | None:
304+
def _find_document_by_query(self, query: Mapping) -> List:
301305
"""
302306
Finds a single ``Document`` of ``Collection``.
303307

0 commit comments

Comments
 (0)