]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
More type:ignore comments for `mypy --py2`
authorBen Darnell <ben@bendarnell.com>
Sun, 17 Apr 2016 17:01:41 +0000 (13:01 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 17 Apr 2016 17:01:41 +0000 (13:01 -0400)
tornado/gen.py
tornado/locale.py
tornado/log.py
tornado/platform/asyncio.py
tornado/testing.py

index 8cffcc0bf0faa8745ffe17133bfd046bddb9de45..7ed8ba87707771a176090ccb99a590efb156078f 100644 (file)
@@ -115,7 +115,8 @@ try:
         from backports_abc import Generator as GeneratorType  # type: ignore
 
     try:
-        from inspect import isawaitable  # py35+
+        # py35+
+        from inspect import isawaitable  # type: ignore
     except ImportError:
         from backports_abc import isawaitable
 except ImportError:
index db7411431682a230a886414f5de4f0ce9321b3ec..4f80fd366382923c410cb71d946e645d25bebf33 100644 (file)
@@ -51,6 +51,7 @@ import re
 
 from tornado import escape
 from tornado.log import gen_log
+from tornado.util import PY3
 
 from tornado._locale_data import LOCALE_NAMES
 
@@ -147,11 +148,11 @@ def load_translations(directory, encoding=None):
                 # in most cases but is common with CSV files because Excel
                 # cannot read utf-8 files without a BOM.
                 encoding = 'utf-8-sig'
-        try:
+        if PY3:
             # python 3: csv.reader requires a file open in text mode.
             # Force utf8 to avoid dependence on $LANG environment variable.
             f = open(full_path, "r", encoding=encoding)
-        except TypeError:
+        else:
             # python 2: csv can only handle byte strings (in ascii-compatible
             # encodings), which we decode below. Transcode everything into
             # utf8 before passing it to csv.reader.
index c8821169a5b1805971a5ca6b153b934dc9adb33e..1d10d3790f61c826c24c53d9e994bd6ceafa1730 100644 (file)
@@ -38,7 +38,7 @@ from tornado.escape import _unicode
 from tornado.util import unicode_type, basestring_type
 
 try:
-    import curses
+    import curses  # type: ignore
 except ImportError:
     curses = None
 
index d5a4899633cf93cf54bd0388fcc845685fc82088..e9a062cf19dd8aac7c43a9078390564ad519db58 100644 (file)
@@ -30,7 +30,7 @@ from tornado import stack_context
 try:
     # Import the real asyncio module for py33+ first.  Older versions of the
     # trollius backport also use this name.
-    import asyncio
+    import asyncio # type: ignore
 except ImportError as e:
     # Asyncio itself isn't available; see if trollius is (backport to py26+).
     try:
index 625334220b2dd37cf65ccb9ff2e6cf020c629855..82a8fa898c79251e0ba0ccce094f71e8ec80f5b1 100644 (file)
@@ -53,8 +53,8 @@ except ImportError:
     from types import GeneratorType  # type: ignore
 
 if sys.version_info >= (3, 5):
-    iscoroutine = inspect.iscoroutine
-    iscoroutinefunction = inspect.iscoroutinefunction
+    iscoroutine = inspect.iscoroutine  # type: ignore
+    iscoroutinefunction = inspect.iscoroutinefunction  # type: ignore
 else:
     iscoroutine = iscoroutinefunction = lambda f: False
 
@@ -69,9 +69,9 @@ if PY3:
 else:
     # On python 2, prefer unittest2 when available.
     try:
-        import unittest2 as unittest
+        import unittest2 as unittest  # type: ignore
     except ImportError:
-        import unittest
+        import unittest  # type: ignore
 
 _next_port = 10000