diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-06-15 16:45:17 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-15 16:45:17 +0900 |
commit | f6dfab33d29cd389c791acf5821adf556df5ca17 (patch) | |
tree | 07ecbae0a006a51567648553cfaa1f03fe6cbdc4 /sphinx/util/pycompat.py | |
parent | 8fd817d174aed3c6655190f904b89f6f7f2ec099 (diff) | |
parent | 5cf84a5505a6063b48e7fcc4d489259ade526912 (diff) | |
download | sphinx-git-f6dfab33d29cd389c791acf5821adf556df5ca17.tar.gz |
Merge branch '2.0' into refactor_todo2
Diffstat (limited to 'sphinx/util/pycompat.py')
-rw-r--r-- | sphinx/util/pycompat.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py index dca2849c2..06d3bcc2c 100644 --- a/sphinx/util/pycompat.py +++ b/sphinx/util/pycompat.py @@ -13,6 +13,7 @@ import io import sys import textwrap import warnings +from typing import Any, Callable from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias from sphinx.locale import __ @@ -20,10 +21,6 @@ from sphinx.util import logging from sphinx.util.console import terminal_safe from sphinx.util.typing import NoneType -if False: - # For type annotation - from typing import Any, Callable # NOQA - logger = logging.getLogger(__name__) @@ -33,8 +30,7 @@ logger = logging.getLogger(__name__) # convert_with_2to3(): # support for running 2to3 over config files -def convert_with_2to3(filepath): - # type: (str) -> str +def convert_with_2to3(filepath: str) -> str: from lib2to3.refactor import RefactoringTool, get_fixers_from_package from lib2to3.pgen2.parse import ParseError fixers = get_fixers_from_package('lib2to3.fixes') @@ -62,8 +58,7 @@ class UnicodeMixin: return self.__unicode__() -def execfile_(filepath, _globals, open=open): - # type: (str, Any, Callable) -> None +def execfile_(filepath: str, _globals: Any, open: Callable = open) -> None: from sphinx.util.osutil import fs_encoding with open(filepath, 'rb') as f: source = f.read() |