aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/hacks.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-03 15:45:35 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-03 16:52:44 -0700
commit91bd35a1ee0993126c369e39fbf8f81f775840ee (patch)
tree87e8bc6257359326f26102e7765e508d5529f0f5 /python/fatcat_web/hacks.py
parent2e92e28df34d302fe02d1e1ff7169b7888648b9c (diff)
downloadfatcat-91bd35a1ee0993126c369e39fbf8f81f775840ee.tar.gz
fatcat-91bd35a1ee0993126c369e39fbf8f81f775840ee.zip
web: add type annotations
This commit does not include type fixes, only annotations. A small number of tuples were also converted to lists.
Diffstat (limited to 'python/fatcat_web/hacks.py')
-rw-r--r--python/fatcat_web/hacks.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/python/fatcat_web/hacks.py b/python/fatcat_web/hacks.py
index 06350b41..0339a0d7 100644
--- a/python/fatcat_web/hacks.py
+++ b/python/fatcat_web/hacks.py
@@ -1,15 +1,17 @@
import re
+from fatcat_openapi_client import WebcaptureEntity
+
STRIP_EXTLINK_XML_RE = re.compile(r"<ext-link.*xlink:type=\"simple\">")
-def strip_extlink_xml(unstr):
+def strip_extlink_xml(unstr: str) -> str:
unstr = unstr.replace("</ext-link>", "")
unstr = STRIP_EXTLINK_XML_RE.sub("", unstr)
return unstr
-def test_strip_extlink_xml():
+def test_strip_extlink_xml() -> None:
assert strip_extlink_xml("asdf") == "asdf"
assert (
strip_extlink_xml(
@@ -19,7 +21,7 @@ def test_strip_extlink_xml():
)
-def wayback_suffix(entity):
+def wayback_suffix(entity: WebcaptureEntity) -> str:
"""
Takes a webcapture entity and returns a suffix to be appended to wayback URLs
"""