Skip to content

Commit eeeb790

Browse files
authored
Merge branch 'master' into type-error
2 parents bfeee65 + bf34c37 commit eeeb790

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
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: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ def find(self, query=None, limit=None) -> List[Document]:
145145
:param query: Condition to search Document
146146
:return: List of Document
147147
"""
148+
if limit is not None and type(limit) == type((1,)):
149+
raise TypeError('Limit should be a tuple')
150+
151+
if query is not None and type(query) == type({}):
152+
raise TypeError('Limit should be a JOSN Object')
153+
148154
# Default result
149155
_result = []
150156

@@ -155,7 +161,7 @@ def find(self, query=None, limit=None) -> List[Document]:
155161
# if limit, Check everything ok
156162
_limit_start = _limit_end = None
157163

158-
if limit:
164+
if limit and type(limit) == type((1, 3)):
159165
if len(limit) == 2:
160166

161167
_limit_start = limit[0]
@@ -184,7 +190,7 @@ def find(self, query=None, limit=None) -> List[Document]:
184190

185191
return _result
186192

187-
elif query is not None:
193+
elif query is not None and type(query) == type({}):
188194
if limit:
189195
for i in self._collection:
190196
_doc = self._find_document_by_query(query)
@@ -218,6 +224,8 @@ def find(self, query=None, limit=None) -> List[Document]:
218224

219225
self._reset_cursor()
220226

227+
228+
221229
return _result
222230

223231
def delete(self, query: Mapping = None) -> List[str]:
@@ -300,7 +308,7 @@ def _reset_cursor(self) -> None:
300308
"""
301309
self._cursor = 0
302310

303-
def _find_document_by_query(self, query: Mapping) -> List | None:
311+
def _find_document_by_query(self, query: Mapping) -> List:
304312
"""
305313
Finds a single ``Document`` of ``Collection``.
306314

0 commit comments

Comments
 (0)