jarun / buku

:bookmark: Personal mini-web in text
GNU General Public License v3.0
6.52k stars 294 forks source link

Return empty list when no matches are found #654

Closed LeXofLeviafan closed 1 year ago

LeXofLeviafan commented 1 year ago

Currently, some BukuDb methods (searchdb(), search_by_tag()) that return a list are returning None instead of an empty list (…sometimes).

This doesn't seem to improve the result usability (empty list is just as falsey as None), and conversely may complicate its processing (since None can't be iterated over nor concatenated). Thus, I suggest always returning a list value in these methods.

…Also, some methods (get_rec_all(), search_keywords_and_filter_by_tag(), exclude_results_from_search()) always return a list (regardless of documented return type), which makes the API inconsistent.

jarun commented 1 year ago

This is OK but make sure you have the correct check in the callers.

jarun commented 1 year ago

From the next suggestion, please share in the buku-dev discussion room. Please don't add one defect for each suggestion.