Skip to content

Commit d55e2df

Browse files
committed
Simplify return type
1 parent ddf1d92 commit d55e2df

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

duckduckgo/query.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ async def zci_extra(q: str,
135135
web_fallback: bool = True,
136136
priority: Tuple[str] = DEFAULT_PRIORITIES,
137137
urls: bool = True,
138-
**kwargs) -> Tuple[str, bool, str]:
138+
**kwargs) -> Tuple[str, str]:
139139
'''A helper method to get a single (and hopefully the best) ZCI result.
140140
priority=list can be used to set the order in which fields will be checked for answers.
141141
Use web_fallback=True to fall back to grabbing the first web result.
142142
passed to query. This method will fall back to 'Sorry, no results.'
143-
if it cannot find anything. Returns a tuple with [result, result_found, result_type] which
143+
if it cannot find anything. Returns a tuple with [result, result_type] which
144144
allows to determine how the result was retrieved.'''
145145

146146
logger.info(f"Performing DDG ZCI: '{q}'")
@@ -149,8 +149,7 @@ async def zci_extra(q: str,
149149

150150
ddg = await query(f'\\{q}', **kwargs)
151151
response = ''
152-
found = True
153-
result_type = ''
152+
result_type = getattr(ddg, 'type', '')
154153

155154
for p in priority:
156155
ps = p.split('.')
@@ -181,15 +180,12 @@ async def zci_extra(q: str,
181180
if not response and web_fallback:
182181
logger.debug("Trying web fallback...")
183182
if ddg.redirect.url:
184-
found = True
185-
result_type = ddg.type
186183
response = ddg.redirect.url
187184

188185
# Final fallback
189186
if not response:
190187
logger.info("No results!")
191-
found = False
192188
response = 'Sorry, no results.'
193189

194190
logger.debug(f"Final response: {response!r}")
195-
return (response, found, result_type)
191+
return (response, result_type)

0 commit comments

Comments
 (0)