|
3 | 3 | """
|
4 | 4 |
|
5 | 5 | import typing
|
6 |
| -from collections import OrderedDict, defaultdict |
| 6 | +from collections import defaultdict |
7 | 7 | from datetime import date, datetime
|
8 | 8 | from time import time
|
9 | 9 | from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Union
|
@@ -55,8 +55,8 @@ def __init__(self, message: Message, model: "Model", last_message: Any) -> None:
|
55 | 55 | self.topic_name = ""
|
56 | 56 | self.email = "" # FIXME: Can we remove this?
|
57 | 57 | self.user_id: Optional[int] = None
|
58 |
| - self.message_links: "OrderedDict[str, Tuple[str, int, bool]]" = OrderedDict() |
59 |
| - self.topic_links: "OrderedDict[str, Tuple[str, int, bool]]" = OrderedDict() |
| 58 | + self.message_links: Dict[str, Tuple[str, int, bool]] = dict() |
| 59 | + self.topic_links: Dict[str, Tuple[str, int, bool]] = dict() |
60 | 60 | self.time_mentions: List[Tuple[str, str]] = list()
|
61 | 61 | self.last_message = last_message
|
62 | 62 | # if this is the first message
|
@@ -295,11 +295,9 @@ def reactions_view(self, reactions: List[Dict[str, Any]]) -> Any:
|
295 | 295 | except Exception:
|
296 | 296 | return ""
|
297 | 297 |
|
298 |
| - # Use quotes as a workaround for OrderedDict typing issue. |
299 |
| - # See https://github.com/python/mypy/issues/6904. |
300 | 298 | @staticmethod
|
301 | 299 | def footlinks_view(
|
302 |
| - message_links: "OrderedDict[str, Tuple[str, int, bool]]", |
| 300 | + message_links: Dict[str, Tuple[str, int, bool]], |
303 | 301 | *,
|
304 | 302 | maximum_footlinks: int,
|
305 | 303 | padded: bool,
|
@@ -357,9 +355,7 @@ def footlinks_view(
|
357 | 355 | @classmethod
|
358 | 356 | def soup2markup(
|
359 | 357 | cls, soup: Any, metadata: Dict[str, Any], **state: Any
|
360 |
| - ) -> Tuple[ |
361 |
| - List[Any], "OrderedDict[str, Tuple[str, int, bool]]", List[Tuple[str, str]] |
362 |
| - ]: |
| 358 | + ) -> Tuple[List[Any], Dict[str, Tuple[str, int, bool]], List[Tuple[str, str]]]: |
363 | 359 | # Ensure a string is provided, in case the soup finds none
|
364 | 360 | # This could occur if eg. an image is removed or not shown
|
365 | 361 | markup: List[Union[str, Tuple[Optional[str], Any]]] = [""]
|
@@ -807,15 +803,15 @@ def transform_content(
|
807 | 803 | cls, content: Any, server_url: str
|
808 | 804 | ) -> Tuple[
|
809 | 805 | Tuple[None, Any],
|
810 |
| - "OrderedDict[str, Tuple[str, int, bool]]", |
| 806 | + Dict[str, Tuple[str, int, bool]], |
811 | 807 | List[Tuple[str, str]],
|
812 | 808 | ]:
|
813 | 809 | soup = BeautifulSoup(content, "lxml")
|
814 | 810 | body = soup.find(name="body")
|
815 | 811 |
|
816 | 812 | metadata = dict(
|
817 | 813 | server_url=server_url,
|
818 |
| - message_links=OrderedDict(), |
| 814 | + message_links=dict(), |
819 | 815 | time_mentions=list(),
|
820 | 816 | ) # type: Dict[str, Any]
|
821 | 817 |
|
|
0 commit comments