preview: Use a dataclass for the embed data.

This is significantly cleaner than passing around `Dict[str, Any]` all
of the time.

(cherry picked from commit 327ff9ea0f)
This commit is contained in:
Alex Vandiver
2022-04-14 12:52:41 -07:00
parent 00b3da0a0c
commit 5ff82c82ae
8 changed files with 180 additions and 190 deletions

View File

@@ -1,5 +1,7 @@
import cgi
from typing import Any, Optional
from typing import Optional
from zerver.lib.url_preview.types import UrlEmbedData
class BaseParser:
@@ -14,5 +16,5 @@ class BaseParser:
charset = cgi.parse_header(content_type)[1].get("charset")
self._soup = BeautifulSoup(html_source, "lxml", from_encoding=charset)
def extract_data(self) -> Any:
def extract_data(self) -> UrlEmbedData:
raise NotImplementedError()