google_search: Add missing type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
602ebb18fe
commit
5c299c7eff
2 changed files with 5 additions and 5 deletions
|
@ -3,7 +3,7 @@ import logging
|
|||
from typing import Dict, List
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from bs4 import BeautifulSoup, Tag
|
||||
|
||||
from zulip_bots.lib import BotHandler
|
||||
|
||||
|
@ -16,7 +16,9 @@ def google_search(keywords: str) -> List[Dict[str, str]]:
|
|||
soup = BeautifulSoup(page.text, "lxml")
|
||||
|
||||
# Gets all search URLs
|
||||
anchors = soup.find(id="search").findAll("a")
|
||||
search = soup.find(id="search")
|
||||
assert isinstance(search, Tag)
|
||||
anchors = search.findAll("a")
|
||||
results = []
|
||||
|
||||
for a in anchors:
|
||||
|
|
|
@ -32,9 +32,7 @@ class TestGoogleSearchBot(BotTestCase, DefaultTests):
|
|||
|
||||
def test_attribute_error(self) -> None:
|
||||
with self.mock_http_conversation("test_attribute_error"), patch("logging.exception"):
|
||||
self.verify_reply(
|
||||
"test", "Error: Search failed. 'NoneType' object has no attribute 'findAll'."
|
||||
)
|
||||
self.verify_reply("test", "Error: Search failed. .")
|
||||
|
||||
# Makes sure cached results, irrelevant links, or empty results are not displayed
|
||||
def test_ignore_links(self) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue