mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-21 15:48:06 -04:00
Fixup synapse.rest to pass mypy (#6732)
This commit is contained in:
parent
74b74462f1
commit
b0a66ab83c
12 changed files with 56 additions and 35 deletions
|
@ -23,6 +23,7 @@ import re
|
|||
import shutil
|
||||
import sys
|
||||
import traceback
|
||||
from typing import Dict, Optional
|
||||
|
||||
import six
|
||||
from six import string_types
|
||||
|
@ -237,8 +238,8 @@ class PreviewUrlResource(DirectServeResource):
|
|||
# If we don't find a match, we'll look at the HTTP Content-Type, and
|
||||
# if that doesn't exist, we'll fall back to UTF-8.
|
||||
if not encoding:
|
||||
match = _content_type_match.match(media_info["media_type"])
|
||||
encoding = match.group(1) if match else "utf-8"
|
||||
content_match = _content_type_match.match(media_info["media_type"])
|
||||
encoding = content_match.group(1) if content_match else "utf-8"
|
||||
|
||||
og = decode_and_calc_og(body, media_info["uri"], encoding)
|
||||
|
||||
|
@ -518,7 +519,7 @@ def _calc_og(tree, media_uri):
|
|||
# "og:video:height" : "720",
|
||||
# "og:video:secure_url": "https://www.youtube.com/v/LXDBoHyjmtw?version=3",
|
||||
|
||||
og = {}
|
||||
og = {} # type: Dict[str, Optional[str]]
|
||||
for tag in tree.xpath("//*/meta[starts-with(@property, 'og:')]"):
|
||||
if "content" in tag.attrib:
|
||||
# if we've got more than 50 tags, someone is taking the piss
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue