Skip to content

Commit 00a3600

Browse files
added documentation and type hinting
1 parent d63d29c commit 00a3600

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

things/api.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
from shlex import quote
99
import sys
10+
from typing import List, Dict
1011

1112
from .database import Database
1213

@@ -16,7 +17,7 @@
1617
# --------------------------------------------------
1718

1819

19-
def tasks(uuid=None, include_items=False, **kwargs):
20+
def tasks(uuid=None, include_items=False, **kwargs): # noqa: C901
2021
"""
2122
Read tasks into dicts.
2223
@@ -314,8 +315,26 @@ def tags(title=None, include_items=False, **kwargs):
314315
# Utility API functions derived from above
315316
# --------------------------------------------------
316317

317-
def search(querystr: str, **kwargs):
318-
return tasks(querystr=querystr, **kwargs)
318+
def search(query: str, **kwargs) -> List[Dict]:
319+
"""
320+
Search the database. This takes mainly notes and titles into account.
321+
322+
Parameters
323+
----------
324+
query : str
325+
The string with optional placeholders (%) to search for.
326+
327+
Returns
328+
-------
329+
list of dict
330+
Representing Things items.
331+
332+
Examples
333+
--------
334+
>>> things.search('substring % within notes and titles')
335+
...
336+
"""
337+
return tasks(querystr=query, **kwargs)
319338

320339

321340
def get(uuid, default=None, **kwargs):

0 commit comments

Comments
 (0)