summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-06-03 23:43:13 +0900
committerGitHub <noreply@github.com>2020-06-03 23:43:13 +0900
commited75950017e63b3ccfe2beef3d22ae6ec44410b0 (patch)
tree0c0ddfd27e4dbe86ad73994523e941ffee5c03e8 /sphinx/util
parente3f9bf43f617b17937df255519337ebda897f46b (diff)
parentb8fbd3d9c64b8bf12d2cdc091798faad7513e820 (diff)
downloadsphinx-git-ed75950017e63b3ccfe2beef3d22ae6ec44410b0.tar.gz
Merge pull request #7775 from tk0miya/mypy-0.780
Fix mypy violations (with mypy-0.780)
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/console.py3
-rw-r--r--sphinx/util/images.py2
-rw-r--r--sphinx/util/nodes.py3
-rw-r--r--sphinx/util/pycompat.py2
-rw-r--r--sphinx/util/template.py2
-rw-r--r--sphinx/util/typing.py8
6 files changed, 10 insertions, 10 deletions
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index 98563f58e..d429be602 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -35,8 +35,7 @@ def get_terminal_width() -> int:
import termios
import fcntl
import struct
- call = fcntl.ioctl(0, termios.TIOCGWINSZ, # type: ignore
- struct.pack('hhhh', 0, 0, 0, 0))
+ call = fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack('hhhh', 0, 0, 0, 0))
height, width = struct.unpack('hhhh', call)[:2]
terminal_width = width
except Exception:
diff --git a/sphinx/util/images.py b/sphinx/util/images.py
index 568682b37..396cb6161 100644
--- a/sphinx/util/images.py
+++ b/sphinx/util/images.py
@@ -54,7 +54,7 @@ def get_image_size(filename: str) -> Tuple[int, int]:
def guess_mimetype_for_stream(stream: IO, default: str = None) -> str:
- imgtype = imghdr.what(stream) # type: ignore
+ imgtype = imghdr.what(stream)
if imgtype:
return 'image/' + imgtype
else:
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index bca6e0bfc..2277b78e6 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -29,6 +29,7 @@ if False:
# For type annotation
from typing import Type # for python3.5.1
from sphinx.builders import Builder
+ from sphinx.domain import IndexEntry
from sphinx.environment import BuildEnvironment
from sphinx.utils.tags import Tags
@@ -313,7 +314,7 @@ def get_prev_node(node: Node) -> Node:
return None
-def traverse_translatable_index(doctree: Element) -> Iterable[Tuple[Element, List[str]]]:
+def traverse_translatable_index(doctree: Element) -> Iterable[Tuple[Element, List["IndexEntry"]]]: # NOQA
"""Traverse translatable index node from a document tree."""
for node in doctree.traverse(NodeMatcher(addnodes.index, inline=False)): # type: addnodes.index # NOQA
if 'raw_entries' in node:
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py
index 061bbcb6d..c7afdabb7 100644
--- a/sphinx/util/pycompat.py
+++ b/sphinx/util/pycompat.py
@@ -83,7 +83,7 @@ def execfile_(filepath: str, _globals: Any, open: Callable = open) -> None:
deprecated_alias('sphinx.util.pycompat',
{
- 'NoneType': NoneType, # type: ignore
+ 'NoneType': NoneType,
'TextIOWrapper': io.TextIOWrapper,
'htmlescape': html.escape,
'indent': textwrap.indent,
diff --git a/sphinx/util/template.py b/sphinx/util/template.py
index 1337f407c..08ca9d06d 100644
--- a/sphinx/util/template.py
+++ b/sphinx/util/template.py
@@ -25,7 +25,7 @@ class BaseRenderer:
def __init__(self, loader: BaseLoader = None) -> None:
self.env = SandboxedEnvironment(loader=loader, extensions=['jinja2.ext.i18n'])
self.env.filters['repr'] = repr
- self.env.install_gettext_translations(get_translator()) # type: ignore
+ self.env.install_gettext_translations(get_translator())
def render(self, template_name: str, context: Dict) -> str:
return self.env.get_template(template_name).render(context)
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index 08bf7203b..f23ed4ce1 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -53,7 +53,7 @@ def stringify(annotation: Any) -> str:
return annotation.__name__
elif not annotation:
return repr(annotation)
- elif annotation is NoneType: # type: ignore
+ elif annotation is NoneType:
return 'None'
elif (getattr(annotation, '__module__', None) == 'builtins' and
hasattr(annotation, '__qualname__')):
@@ -91,7 +91,7 @@ def _stringify_py37(annotation: Any) -> str:
if getattr(annotation, '__args__', None):
if qualname == 'Union':
- if len(annotation.__args__) == 2 and annotation.__args__[1] is NoneType: # type: ignore # NOQA
+ if len(annotation.__args__) == 2 and annotation.__args__[1] is NoneType:
return 'Optional[%s]' % stringify(annotation.__args__[0])
else:
args = ', '.join(stringify(a) for a in annotation.__args__)
@@ -161,7 +161,7 @@ def _stringify_py36(annotation: Any) -> str:
hasattr(annotation, '__union_params__')): # for Python 3.5
params = annotation.__union_params__
if params is not None:
- if len(params) == 2 and params[1] is NoneType: # type: ignore
+ if len(params) == 2 and params[1] is NoneType:
return 'Optional[%s]' % stringify(params[0])
else:
param_str = ', '.join(stringify(p) for p in params)
@@ -170,7 +170,7 @@ def _stringify_py36(annotation: Any) -> str:
annotation.__origin__ is typing.Union): # for Python 3.5.2+
params = annotation.__args__
if params is not None:
- if len(params) == 2 and params[1] is NoneType: # type: ignore
+ if len(params) == 2 and params[1] is NoneType:
return 'Optional[%s]' % stringify(params[0])
else:
param_str = ', '.join(stringify(p) for p in params)