Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
html_branches: Fix strict_optional errors.
Anders Kaseorg8a03f8a0704b
diff --git a/mypy.ini b/mypy.iniindex 99d361208f0..eb93645605a 100644--- a/mypy.ini+++ b/mypy.ini@@ -40,8 +40,5 @@ strict_optional = True# General exclusions to work on-[mypy-tools.lib.html_branches]-strict_optional = False-[mypy-zthumbor.loaders.helpers]strict_optional = Falsediff --git a/tools/lib/html_branches.py b/tools/lib/html_branches.pyindex 0d6b36fd475..3e5eb760759 100644--- a/tools/lib/html_branches.py+++ b/tools/lib/html_branches.py@@ -53,7 +53,7 @@ class HtmlTreeBranch:class Node:- def __init__(self, token: Token, parent: "Optional[Node]") -> None:+ def __init__(self, token: Optional[Token], parent: "Optional[Node]") -> None:# FIXME parent parameter is not used!self.token = tokenself.children: List[Node] = []@@ -133,6 +133,7 @@ def html_branches(text: str, fn: Optional[str] = None) -> List[HtmlTreeBranch]:branches: List[HtmlTreeBranch] = []def walk(node: Node, tag_info_list: Sequence[TagInfo] = []) -> None:+ assert node.token is not Noneinfo = get_tag_info(node.token)tag_info_list = [*tag_info_list, info]diff --git a/tools/tests/test_html_branches.py b/tools/tests/test_html_branches.pyindex 36d268a255b..957412f2925 100644--- a/tools/tests/test_html_branches.py+++ b/tools/tests/test_html_branches.py@@ -49,24 +49,31 @@ class TestHtmlBranches(unittest.TestCase):tree = html_tag_tree(html)+ assert tree.children[0].token is not Noneself.assertEqual(tree.children[0].token.kind, 'html_start')self.assertEqual(tree.children[0].token.tag, 'html')+ assert tree.children[0].children[0].token is not Noneself.assertEqual(tree.children[0].children[0].token.kind, 'html_start')self.assertEqual(tree.children[0].children[0].token.tag, 'head')+ assert tree.children[0].children[0].children[0].token is not Noneself.assertEqual(tree.children[0].children[0].children[0].token.kind, 'html_start')self.assertEqual(tree.children[0].children[0].children[0].token.tag, 'title')+ assert tree.children[0].children[1].token is not Noneself.assertEqual(tree.children[0].children[1].token.kind, 'html_start')self.assertEqual(tree.children[0].children[1].token.tag, 'body')+ assert tree.children[0].children[1].children[0].token is not Noneself.assertEqual(tree.children[0].children[1].children[0].token.kind, 'html_start')self.assertEqual(tree.children[0].children[1].children[0].token.tag, 'p')+ assert tree.children[0].children[1].children[0].children[0].token is not Noneself.assertEqual(tree.children[0].children[1].children[0].children[0].token.kind, 'html_singleton')self.assertEqual(tree.children[0].children[1].children[0].children[0].token.tag, 'br')+ assert tree.children[0].children[1].children[1].token is not Noneself.assertEqual(tree.children[0].children[1].children[1].token.kind, 'html_start')self.assertEqual(tree.children[0].children[1].children[1].token.tag, 'p')