Merge pull request #6133 from tk0miya/cleanup_import_for_annotations

Clean up import for annotations
This commit is contained in:
Takeshi KOMIYA 2019-03-07 00:28:57 +09:00 committed by GitHub
commit e0c2d7568a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 36 additions and 66 deletions

View File

@ -40,7 +40,7 @@ except ImportError:
if False:
# For type annotation
from typing import Any, Callable, Dict, Iterable, List, Sequence, Set, Tuple, Type, Union # NOQA
from typing import Any, Dict, Iterable, List, Sequence, Set, Tuple, Type, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -36,7 +36,6 @@ except ImportError:
if False:
# For type annotation
from typing import Any, Dict, List, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
logger = logging.getLogger(__name__)

View File

@ -25,8 +25,7 @@ from sphinx.util.osutil import make_filename
if False:
# For type annotation
from typing import Any, Dict, Iterable, List, Set, Tuple # NOQA
from docutils import nodes # NOQA
from typing import Any, Dict, List, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA

View File

@ -11,6 +11,7 @@
import os
from os import path
from docutils import nodes
from docutils.frontend import OptionParser
import sphinx.builders.latex.nodes # NOQA # Workaround: import this before writer to avoid ImportError
@ -42,7 +43,6 @@ from sphinx.writers.latex import (
if False:
# For type annotation
from docutils import nodes # NOQA
from typing import Any, Dict, Iterable, List, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
@ -295,7 +295,6 @@ class LaTeXBuilder(Builder):
def assemble_doctree(self, indexfile, toctree_only, appendices):
# type: (str, bool, List[str]) -> nodes.document
from docutils import nodes # NOQA
self.docnames = set([indexfile] + appendices)
logger.info(darkgreen(indexfile) + " ", nonl=True)
tree = self.env.get_doctree(indexfile)

View File

@ -21,7 +21,7 @@ from sphinx.util.nodes import NodeMatcher
if False:
# For type annotation
from typing import Any, Dict, List, Set, Tuple, Union # NOQA
from typing import Any, List, Set, Tuple # NOQA
URI_SCHEMES = ('mailto:', 'http:', 'https:', 'ftp:')

View File

@ -30,7 +30,7 @@ from sphinx.util.requests import is_ssl_error
if False:
# For type annotation
from typing import Any, Dict, List, Set, Tuple, Union # NOQA
from typing import Any, Dict, List, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.util.requests.requests import Response # NOQA

View File

@ -27,7 +27,7 @@ from sphinx.util.typing import NoneType
if False:
# For type annotation
from typing import Any, Callable, Dict, Generator, Iterator, List, Set, Tuple, Union # NOQA
from typing import Callable, Dict, Generator, Iterator, List, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.util.tags import Tags # NOQA

View File

@ -35,8 +35,6 @@ if False:
# For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.util.docfields import Field # NOQA
from sphinx.util.typing import DirectiveOption # NOQA

View File

@ -26,7 +26,7 @@ from sphinx.util.nodes import explicit_title_re, set_source_info, \
if False:
# For type annotation
from typing import Any, Dict, Generator, List, Tuple # NOQA
from typing import Any, Dict, List # NOQA
from sphinx.application import Sphinx # NOQA

View File

@ -24,7 +24,6 @@ from sphinx.util.nodes import make_refnode
if False:
# For type annotation
from typing import Any, Dict, Iterator, List, Tuple # NOQA
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -20,7 +20,7 @@ from sphinx.util.nodes import make_refnode
if False:
# For type annotation
from typing import Any, Callable, Dict, Iterable, List, Tuple, Type, Union # NOQA
from typing import Any, Dict, Iterable, List, Tuple # NOQA
from sphinx import addnodes # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA

View File

@ -26,7 +26,7 @@ from sphinx.util.nodes import make_refnode
if False:
# For type annotation
from typing import Any, Dict, Iterable, Iterator, List, Tuple, Type, Union # NOQA
from typing import Any, Dict, Iterable, Iterator, List, Tuple, Type # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -30,7 +30,7 @@ from sphinx.util.nodes import is_translatable
if False:
# For type annotation
from typing import Any, Callable, Dict, IO, Iterator, List, Optional, Pattern, Set, Tuple, Type, Union, Generator # NOQA
from typing import Any, Callable, Dict, IO, Iterator, List, Optional, Set, Tuple, Union # NOQA
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA

View File

@ -24,8 +24,7 @@ from sphinx.util.images import guess_mimetype
if False:
# For type annotation
from typing import Dict, List, Set, Tuple # NOQA
from docutils import nodes # NOQA
from typing import Dict, List, Set # NOQA
from sphinx.sphinx import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -17,7 +17,6 @@ from sphinx.environment.collectors import EnvironmentCollector
if False:
# For type annotation
from typing import Dict, Set # NOQA
from docutils import nodes # NOQA
from sphinx.sphinx import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -16,7 +16,6 @@ from sphinx.transforms import SphinxContentsFilter
if False:
# For type annotation
from typing import Dict, Set # NOQA
from docutils import nodes # NOQA
from sphinx.sphinx import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -21,9 +21,8 @@ from sphinx.util import url_re, logging
if False:
# For type annotation
from typing import Any, Dict, List, Set, Tuple, Type, TypeVar # NOQA
from typing import Dict, List, Set, Tuple, Type, TypeVar # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA
N = TypeVar('N')

View File

@ -33,9 +33,7 @@ from sphinx.util.inspect import Signature, isdescriptor, safe_getmembers, \
if False:
# For type annotation
from types import ModuleType # NOQA
from typing import Any, Callable, Dict, Iterator, List, Sequence, Set, Tuple, Type, Union # NOQA
from docutils import nodes # NOQA
from docutils.utils import Reporter # NOQA
from typing import Callable, Dict, Iterator, List, Sequence, Set, Tuple, Type, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -17,9 +17,8 @@ from sphinx.util.nodes import nested_parse_with_titles
if False:
# For type annotation
from typing import Any, Callable, Dict, List, Set, Type # NOQA
from typing import Callable, Dict, List, Set, Type # NOQA
from docutils.parsers.rst.state import RSTState # NOQA
from docutils.statemachine import StateMachine, StringList # NOQA
from docutils.utils import Reporter # NOQA
from sphinx.config import Config # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -24,7 +24,7 @@ from sphinx.util.inspect import isenumclass, safe_getattr
if False:
# For type annotation
from typing import Any, Callable, Dict, Generator, Iterator, List, Optional, Sequence, Tuple, Union # NOQA
from typing import Any, Callable, Dict, Generator, Iterator, List, Sequence, Tuple, Union # NOQA
logger = logging.getLogger(__name__)

View File

@ -24,11 +24,6 @@ if False:
logger = logging.getLogger(__name__)
if False:
# For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
def get_node_depth(node):
i = 0

View File

@ -41,9 +41,7 @@ from sphinx.util.rst import escape as rst_escape
if False:
# For type annotation
from typing import Any, Callable, Dict, List, Tuple, Type, Union # NOQA
from sphinx import addnodes # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.ext.autodoc import Documenter # NOQA

View File

@ -23,7 +23,7 @@ from sphinx.util.inspect import safe_getattr
if False:
# For type annotation
from typing import Any, Callable, Dict, IO, List, Pattern, Set, Tuple # NOQA
from typing import Any, Dict, IO, List, Pattern, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
logger = logging.getLogger(__name__)

View File

@ -34,7 +34,7 @@ from sphinx.util.osutil import relpath
if False:
# For type annotation
from typing import Any, Callable, Dict, IO, Iterable, List, Optional, Sequence, Set, Tuple, Type # NOQA
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type # NOQA
from sphinx.application import Sphinx # NOQA
logger = logging.getLogger(__name__)

View File

@ -31,7 +31,6 @@ from sphinx.util.png import read_png_depth, write_png_depth
if False:
# For type annotation
from typing import Any, Dict, List, Tuple, Union # NOQA
from sphinx.addnodes import displaymath # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.config import Config # NOQA

View File

@ -55,7 +55,7 @@ from sphinx.util.docutils import SphinxDirective
if False:
# For type annotation
from typing import Any, Dict, List, Tuple, Dict, Optional # NOQA
from typing import Any, Dict, List, Optional, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.writers.html import HTMLTranslator # NOQA

View File

@ -41,7 +41,7 @@ from sphinx.util.inventory import InventoryFile
if False:
# For type annotation
from typing import Any, Dict, IO, List, Tuple, Union # NOQA
from typing import Any, Dict, IO, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -22,7 +22,7 @@ from sphinx.domains.math import MathReferenceRole as EqXRefRole # NOQA # to ke
if False:
# For type annotation
from typing import Any, Callable, List, Tuple # NOQA
from typing import Callable, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.writers.html import HTMLTranslator # NOQA

View File

@ -14,7 +14,7 @@ import warnings
from pygments import highlight
from pygments.filters import ErrorToken
from pygments.formatters import HtmlFormatter, LatexFormatter
from pygments.lexer import Lexer # NOQA
from pygments.lexer import Lexer
from pygments.lexers import get_lexer_by_name, guess_lexer
from pygments.lexers import PythonLexer, Python3Lexer, PythonConsoleLexer, \
CLexer, TextLexer, RstLexer

View File

@ -9,6 +9,7 @@
"""
import codecs
import warnings
from typing import Any
from docutils.core import Publisher
from docutils.io import FileInput, NullOutput
@ -16,7 +17,6 @@ from docutils.parsers.rst import Parser as RSTParser
from docutils.readers import standalone
from docutils.statemachine import StringList, string2lines
from docutils.writers import UnfilteredWriter
from typing import Any, Union # NOQA
from sphinx.deprecation import RemovedInSphinx30Warning
from sphinx.transforms import (
@ -39,14 +39,13 @@ from sphinx.versioning import UIDTransform
if False:
# For type annotation
from typing import Any, Dict, List, Tuple, Type, Union # NOQA
from typing import Dict, List, Tuple, Type # NOQA
from docutils import nodes # NOQA
from docutils.frontend import Values # NOQA
from docutils.io import Input # NOQA
from docutils.parsers import Parser # NOQA
from docutils.transforms import Transform # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA

View File

@ -23,7 +23,7 @@ from sphinx.util.osutil import mtimes_of_files
if False:
# For type annotation
from typing import Any, Callable, Dict, List, Iterator, Tuple, Union # NOQA
from typing import Dict, List, Union # NOQA
from jinja2.environment import Environment # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.theming import Theme # NOQA

View File

@ -18,7 +18,7 @@ from sphinx.deprecation import RemovedInSphinx30Warning
if False:
# For type annotation
from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple, Union # NOQA
from typing import Any, Callable, Dict, Iterable, List, Tuple, Union # NOQA
class _TranslationProxy(UserString):

View File

@ -18,7 +18,7 @@ from tokenize import COMMENT, NL
if False:
# For type annotation
from typing import Any, Dict, IO, List, Tuple # NOQA
from typing import Any, Dict, List, Tuple # NOQA
comment_re = re.compile('^\\s*#: ?(.*)\r?\n?$')
indent_re = re.compile('^\\s*$')

View File

@ -25,7 +25,7 @@ from sphinx.util.osutil import abspath
if False:
# For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from typing import Any, Dict # NOQA
class BuildDoc(Command):

View File

@ -25,7 +25,6 @@ from sphinx.util.osutil import relpath
if False:
# For type annotation
from typing import List # NOQA
from typing import Any, Dict, Generator, IO, List, Pattern # NOQA

View File

@ -27,7 +27,7 @@ logger = logging.getLogger(__name__)
if False:
# For type annotation
from typing import Any, Dict, Iterator, List, Tuple # NOQA
from typing import Any, Dict, List # NOQA
from sphinx.application import Sphinx # NOQA
NODEFAULT = object()

View File

@ -20,12 +20,8 @@ from sphinx.util import logging
if False:
# For type annotation
from typing import Any, Callable, Dict, Iterable, List, Tuple # NOQA
from docutils.parsers.rst.states import Inliner # NOQA
from docutils.writers.html4css1 import Writer # NOQA
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA
logger = logging.getLogger(__name__)

View File

@ -48,7 +48,7 @@ from sphinx.util.matching import patfilter # noqa
if False:
# For type annotation
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Pattern, Sequence, Set, Tuple, Type, Union # NOQA
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Pattern, Set, Tuple, Type, Union # NOQA
logger = logging.getLogger(__name__)

View File

@ -18,7 +18,6 @@ from sphinx import addnodes
if False:
# For type annotation
from typing import Any, Dict, Type, Union # NOQA
from sphinx.domains import Domain # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.util.typing import TextlikeNode # NOQA

View File

@ -42,7 +42,6 @@ if False:
from sphinx.builders import Builder # NOQA
from sphinx.config import Config # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.io import SphinxFileInput # NOQA
from sphinx.util.typing import RoleFunction # NOQA

View File

@ -27,7 +27,7 @@ except ImportError:
if False:
# For type annotation
from typing import Dict, IO, List, Tuple # NOQA
from typing import IO, Tuple # NOQA
mime_suffixes = OrderedDict([
('.gif', 'image/gif'),

View File

@ -15,7 +15,7 @@ from sphinx.util import logging
if False:
# For type annotation
from typing import Callable, Dict, IO, Iterator, Tuple # NOQA
from typing import Callable, IO, Iterator # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.util.typing import Inventory # NOQA

View File

@ -22,7 +22,6 @@ from sphinx.util.console import colorize
if False:
# For type annotation
from typing import Any, Dict, Generator, IO, List, Tuple, Type, Union # NOQA
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA

View File

@ -19,7 +19,7 @@ from sphinx.util import logging
if False:
# For type annotation
from typing import Any, Callable, Iterable, List, Optional, Set, Tuple, Type # NOQA
from typing import Callable, Iterable, List, Optional, Set, Tuple, Type # NOQA
from docutils.parsers.rst.states import Inliner # NOQA
from docutils.statemachine import StringList # NOQA
from sphinx.builders import Builder # NOQA

View File

@ -24,7 +24,7 @@ from sphinx.deprecation import RemovedInSphinx30Warning, RemovedInSphinx40Warnin
if False:
# For type annotation
from typing import Any, Iterator, List, Tuple, Union # NOQA
from typing import Any, Iterator, List, Tuple # NOQA
# Errnos that we need.
EEXIST = getattr(errno, 'EEXIST', 0) # RemovedInSphinx40Warning

View File

@ -22,7 +22,7 @@ from sphinx.util.typing import NoneType
if False:
# For type annotation
from typing import Any, Callable, Generator # NOQA
from typing import Any, Callable # NOQA
logger = logging.getLogger(__name__)

View File

@ -12,7 +12,7 @@ from docutils.writers.docutils_xml import Writer as BaseXMLWriter
if False:
# For type annotation
from typing import Any, Tuple # NOQA
from typing import Any # NOQA
from sphinx.builders import Builder # NOQA