From 1eb16d03a28a89c720cb5e8f244a572c0a23570d Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 12 Sep 2016 09:03:37 -0700 Subject: [PATCH] Finish annotating template/css parsers and tests. --- tools/lib/template_parser.py | 3 ++- tools/tests/test_css_parser.py | 5 ++--- tools/tests/test_template_parser.py | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py index 2d9afd4042..0d38e7cfa4 100644 --- a/tools/lib/template_parser.py +++ b/tools/lib/template_parser.py @@ -25,6 +25,7 @@ class Token(object): self.col = col def tokenize(text): + # type: (str) -> List[Token] def advance(n): # type: (int) -> None for _ in range(n): @@ -119,7 +120,7 @@ def tokenize(text): return tokens def validate(fn=None, text=None, check_indent=True): - # type: (str, str, bool) -> None + # type: (Optional[str], Optional[str], bool) -> None assert fn or text if fn is None: diff --git a/tools/tests/test_css_parser.py b/tools/tests/test_css_parser.py index 56c3b84410..c0321bf465 100644 --- a/tools/tests/test_css_parser.py +++ b/tools/tests/test_css_parser.py @@ -119,9 +119,8 @@ class ParserTestSadPath(unittest.TestCase): ''' def _assert_error(self, my_css, error): - # See https://github.com/python/typeshed/issues/372 - # for why we have to ingore types here. - with self.assertRaisesRegexp(CssParserException, error): # type: ignore + # type: (str, str) -> None + with self.assertRaisesRegexp(CssParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372 parse(my_css) def test_unexpected_end_brace(self): diff --git a/tools/tests/test_template_parser.py b/tools/tests/test_template_parser.py index f2b408667d..32503c21db 100644 --- a/tools/tests/test_template_parser.py +++ b/tools/tests/test_template_parser.py @@ -1,6 +1,8 @@ from __future__ import absolute_import from __future__ import print_function +from typing import Optional + import sys import unittest @@ -17,9 +19,8 @@ except ImportError: class ParserTest(unittest.TestCase): def _assert_validate_error(self, error, fn=None, text=None, check_indent=True): - # See https://github.com/python/typeshed/issues/372 - # for why we have to ingore types here. - with self.assertRaisesRegexp(TemplateParserException, error): # type: ignore + # type: (str, Optional[str], Optional[str], bool) -> None + with self.assertRaisesRegexp(TemplateParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372 validate(fn=fn, text=text, check_indent=check_indent) def test_is_django_block_tag(self):