From 7e39e2c6262f778610b0197de17ccb320985ed14 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 3 Mar 2018 02:28:58 +0900 Subject: [PATCH] Fix mypy violations --- sphinx/deprecation.py | 9 +++++++-- sphinx/locale/__init__.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sphinx/deprecation.py b/sphinx/deprecation.py index 905d19a07..1b0e862f0 100644 --- a/sphinx/deprecation.py +++ b/sphinx/deprecation.py @@ -11,6 +11,11 @@ import warnings +if False: + # For type annotation + # note: Don't use typing.TYPE_CHECK here (for py27 and py34). + from typing import Any, Dict, Type # NOQA + class RemovedInSphinx18Warning(DeprecationWarning): pass @@ -35,7 +40,7 @@ class DeprecatedDict(dict): """A deprecated dict which warns on each access.""" def __init__(self, data, message, warning): - # type: (Dict, str, DeprecationWarning) -> None + # type: (Dict, str, Type[Warning]) -> None self.message = message self.warning = warning super(DeprecatedDict, self).__init__(data) @@ -51,7 +56,7 @@ class DeprecatedDict(dict): return super(DeprecatedDict, self).setdefault(key, default) def __getitem__(self, key): - # type: (unicode, Any) -> None + # type: (unicode) -> None warnings.warn(self.message, self.warning) return super(DeprecatedDict, self).__getitem__(key) diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index bca13ef94..afd31f276 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -345,7 +345,7 @@ admonitionlabels = { } # type: Dict[unicode, unicode] # Moved to sphinx.directives.other (will be overrided later) -versionlabels = {} +versionlabels = {} # type: Dict[unicode, unicode] # Moved to sphinx.domains.python (will be overrided later) -pairindextypes = {} +pairindextypes = {} # type: Dict[unicode, unicode]