Merge pull request #6747 from tk0miya/mypy-0.740

Fix mypy violations (for mypy-0.740)
This commit is contained in:
Takeshi KOMIYA 2019-10-20 13:41:49 +09:00 committed by GitHub
commit f30e2af762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 7 deletions

View File

@ -47,7 +47,7 @@ extras_require = {
'html5lib', 'html5lib',
'flake8>=3.5.0', 'flake8>=3.5.0',
'flake8-import-order', 'flake8-import-order',
'mypy>=0.730', 'mypy>=0.740',
'docutils-stubs', 'docutils-stubs',
], ],
} }

View File

@ -32,7 +32,8 @@ from sphinx.util.nodes import make_refnode
if False: if False:
# For type annotation # For type annotation
from typing import Any, Callable, Dict, Iterator, List, Match, Pattern, Tuple, Union # NOQA from docutils.nodes import TextElement
from typing import Any, Callable, Dict, Iterator, List, Match, Pattern, Tuple, Type, Union # NOQA
from sphinx.application import Sphinx # NOQA from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA from sphinx.builders import Builder # NOQA
from sphinx.config import Config # NOQA from sphinx.config import Config # NOQA
@ -6980,7 +6981,7 @@ class CPPExprRole:
if asCode: if asCode:
# render the expression as inline code # render the expression as inline code
self.class_type = 'cpp-expr' self.class_type = 'cpp-expr'
self.node_type = nodes.literal self.node_type = nodes.literal # type: Type[TextElement]
else: else:
# render the expression as inline text # render the expression as inline text
self.class_type = 'cpp-texpr' self.class_type = 'cpp-texpr'

View File

@ -187,7 +187,7 @@ class sphinx_domains:
def __enter__(self) -> None: def __enter__(self) -> None:
self.enable() self.enable()
def __exit__(self, exc_type: "Type[Exception]", exc_value: Exception, traceback: Any) -> bool: # NOQA def __exit__(self, exc_type: "Type[Exception]", exc_value: Exception, traceback: Any) -> bool: # type: ignore # NOQA
self.disable() self.disable()
return False return False

View File

@ -9,7 +9,7 @@
""" """
import re import re
from typing import Callable, Dict, List, Match, Pattern from typing import Callable, Dict, Iterable, List, Match, Pattern
from sphinx.util.osutil import canon_path from sphinx.util.osutil import canon_path
@ -96,7 +96,7 @@ def patmatch(name: str, pat: str) -> Match[str]:
return _pat_cache[pat].match(name) return _pat_cache[pat].match(name)
def patfilter(names: List[str], pat: str) -> List[str]: def patfilter(names: Iterable[str], pat: str) -> List[str]:
"""Return the subset of the list NAMES that match PAT. """Return the subset of the list NAMES that match PAT.
Adapted from fnmatch module. Adapted from fnmatch module.

View File

@ -55,7 +55,7 @@ class UnicodeMixin:
def __str__(self): def __str__(self):
warnings.warn('UnicodeMixin is deprecated', warnings.warn('UnicodeMixin is deprecated',
RemovedInSphinx40Warning, stacklevel=2) RemovedInSphinx40Warning, stacklevel=2)
return self.__unicode__() return self.__unicode__() # type: ignore
def execfile_(filepath: str, _globals: Any, open: Callable = open) -> None: def execfile_(filepath: str, _globals: Any, open: Callable = open) -> None: