Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sphinx
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx')
-rw-r--r--sphinx/addnodes.py5
-rw-r--r--sphinx/application.py6
-rw-r--r--sphinx/builders/__init__.py4
-rw-r--r--sphinx/builders/_epub_base.py4
-rw-r--r--sphinx/builders/applehelp.py4
-rw-r--r--sphinx/builders/changes.py4
-rw-r--r--sphinx/builders/devhelp.py4
-rw-r--r--sphinx/builders/dummy.py4
-rw-r--r--sphinx/builders/epub3.py4
-rw-r--r--sphinx/builders/gettext.py4
-rw-r--r--sphinx/builders/html.py4
-rw-r--r--sphinx/builders/htmlhelp.py4
-rw-r--r--sphinx/builders/latex.py4
-rw-r--r--sphinx/builders/linkcheck.py4
-rw-r--r--sphinx/builders/manpage.py4
-rw-r--r--sphinx/builders/qthelp.py4
-rw-r--r--sphinx/builders/texinfo.py4
-rw-r--r--sphinx/builders/text.py4
-rw-r--r--sphinx/builders/websupport.py5
-rw-r--r--sphinx/builders/xml.py4
-rw-r--r--sphinx/cmd/build.py4
-rw-r--r--sphinx/cmd/quickstart.py4
-rw-r--r--sphinx/cmdline.py4
-rw-r--r--sphinx/config.py5
-rw-r--r--sphinx/directives/__init__.py4
-rw-r--r--sphinx/directives/code.py4
-rw-r--r--sphinx/directives/other.py5
-rw-r--r--sphinx/directives/patches.py5
-rw-r--r--sphinx/domains/__init__.py4
-rw-r--r--sphinx/domains/c.py4
-rw-r--r--sphinx/domains/cpp.py4
-rw-r--r--sphinx/domains/javascript.py5
-rw-r--r--sphinx/domains/python.py4
-rw-r--r--sphinx/domains/rst.py4
-rw-r--r--sphinx/domains/std.py4
-rw-r--r--sphinx/environment/__init__.py4
-rw-r--r--sphinx/environment/adapters/asset.py5
-rw-r--r--sphinx/environment/adapters/indexentries.py4
-rw-r--r--sphinx/environment/adapters/toctree.py5
-rw-r--r--sphinx/environment/collectors/__init__.py5
-rw-r--r--sphinx/environment/collectors/asset.py4
-rw-r--r--sphinx/environment/collectors/dependencies.py4
-rw-r--r--sphinx/environment/collectors/indexentries.py5
-rw-r--r--sphinx/environment/collectors/metadata.py5
-rw-r--r--sphinx/environment/collectors/title.py5
-rw-r--r--sphinx/environment/collectors/toctree.py5
-rw-r--r--sphinx/errors.py5
-rw-r--r--sphinx/events.py4
-rw-r--r--sphinx/ext/apidoc.py4
-rw-r--r--sphinx/ext/autodoc/__init__.py4
-rw-r--r--sphinx/ext/autodoc/directive.py5
-rw-r--r--sphinx/ext/autodoc/importer.py4
-rw-r--r--sphinx/ext/autodoc/inspector.py4
-rw-r--r--sphinx/ext/autosectionlabel.py7
-rw-r--r--sphinx/ext/autosummary/__init__.py4
-rw-r--r--sphinx/ext/autosummary/generate.py4
-rw-r--r--sphinx/ext/coverage.py4
-rw-r--r--sphinx/ext/doctest.py4
-rw-r--r--sphinx/ext/graphviz.py4
-rw-r--r--sphinx/ext/ifconfig.py5
-rw-r--r--sphinx/ext/imgconverter.py4
-rw-r--r--sphinx/ext/imgmath.py4
-rw-r--r--sphinx/ext/inheritance_diagram.py4
-rw-r--r--sphinx/ext/intersphinx.py4
-rw-r--r--sphinx/ext/linkcode.py5
-rw-r--r--sphinx/ext/mathbase.py6
-rw-r--r--sphinx/ext/napoleon/__init__.py4
-rw-r--r--sphinx/ext/napoleon/docstring.py4
-rw-r--r--sphinx/ext/napoleon/iterators.py4
-rw-r--r--sphinx/ext/todo.py5
-rw-r--r--sphinx/ext/viewcode.py4
-rw-r--r--sphinx/extension.py5
-rw-r--r--sphinx/highlighting.py5
-rw-r--r--sphinx/io.py6
-rw-r--r--sphinx/jinja2glue.py5
-rw-r--r--sphinx/locale/__init__.py4
-rw-r--r--sphinx/make_mode.py28
-rw-r--r--sphinx/parsers.py5
-rw-r--r--sphinx/pycode/__init__.py5
-rw-r--r--sphinx/pycode/parser.py4
-rw-r--r--sphinx/registry.py6
-rw-r--r--sphinx/roles.py4
-rw-r--r--sphinx/search/__init__.py4
-rw-r--r--sphinx/search/da.py5
-rw-r--r--sphinx/search/de.py5
-rw-r--r--sphinx/search/en.py5
-rw-r--r--sphinx/search/es.py5
-rw-r--r--sphinx/search/fi.py5
-rw-r--r--sphinx/search/fr.py5
-rw-r--r--sphinx/search/hu.py5
-rw-r--r--sphinx/search/it.py5
-rw-r--r--sphinx/search/ja.py4
-rw-r--r--sphinx/search/nl.py5
-rw-r--r--sphinx/search/no.py5
-rw-r--r--sphinx/search/pt.py5
-rw-r--r--sphinx/search/ro.py5
-rw-r--r--sphinx/search/ru.py5
-rw-r--r--sphinx/search/sv.py5
-rw-r--r--sphinx/search/tr.py5
-rw-r--r--sphinx/search/zh.py4
-rw-r--r--sphinx/setup_command.py4
-rw-r--r--sphinx/testing/fixtures.py4
-rw-r--r--sphinx/testing/util.py5
-rw-r--r--sphinx/theming.py4
-rw-r--r--sphinx/transforms/__init__.py6
-rw-r--r--sphinx/transforms/compact_bullet_list.py5
-rw-r--r--sphinx/transforms/i18n.py4
-rw-r--r--sphinx/transforms/post_transforms/__init__.py4
-rw-r--r--sphinx/transforms/post_transforms/images.py4
-rw-r--r--sphinx/util/__init__.py4
-rw-r--r--sphinx/util/compat.py4
-rw-r--r--sphinx/util/console.py5
-rw-r--r--sphinx/util/docfields.py5
-rw-r--r--sphinx/util/docstrings.py5
-rw-r--r--sphinx/util/docutils.py4
-rw-r--r--sphinx/util/fileutil.py4
-rw-r--r--sphinx/util/i18n.py6
-rw-r--r--sphinx/util/images.py5
-rw-r--r--sphinx/util/inspect.py4
-rw-r--r--sphinx/util/inventory.py6
-rw-r--r--sphinx/util/jsdump.py5
-rw-r--r--sphinx/util/jsonimpl.py5
-rw-r--r--sphinx/util/logging.py4
-rw-r--r--sphinx/util/matching.py5
-rw-r--r--sphinx/util/nodes.py4
-rw-r--r--sphinx/util/osutil.py5
-rw-r--r--sphinx/util/parallel.py5
-rw-r--r--sphinx/util/pycompat.py5
-rw-r--r--sphinx/util/requests.py4
-rw-r--r--sphinx/util/rst.py6
-rw-r--r--sphinx/util/smartypants.py3
-rw-r--r--sphinx/util/tags.py6
-rw-r--r--sphinx/util/template.py5
-rw-r--r--sphinx/versioning.py4
-rw-r--r--sphinx/writers/html.py4
-rw-r--r--sphinx/writers/html5.py4
-rw-r--r--sphinx/writers/latex.py9
-rw-r--r--sphinx/writers/manpage.py5
-rw-r--r--sphinx/writers/texinfo.py4
-rw-r--r--sphinx/writers/text.py4
-rw-r--r--sphinx/writers/xml.py5
141 files changed, 315 insertions, 351 deletions
diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py
index 950b9b8ca..e6999bd16 100644
--- a/sphinx/addnodes.py
+++ b/sphinx/addnodes.py
@@ -9,11 +9,10 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import List, Sequence # NOQA
diff --git a/sphinx/application.py b/sphinx/application.py
index 32d6384ed..8c726b091 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -19,7 +19,6 @@ import warnings
from collections import deque
from inspect import isclass
from os import path
-from typing import TYPE_CHECKING
from docutils.parsers.rst import Directive, directives, roles
from six import itervalues
@@ -47,11 +46,12 @@ from sphinx.util.i18n import find_catalog_source_files
from sphinx.util.osutil import abspath, ensuredir
from sphinx.util.tags import Tags
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Tuple, Type, Union # NOQA
from docutils import nodes # NOQA
from docutils.parsers import Parser # NOQA
- from docutils.transform import Transform # NOQA
+ from docutils.transforms import Transform # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.domains import Domain, Index # NOQA
from sphinx.environment.collectors import EnvironmentCollector # NOQA
diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py
index 3dcc117ea..a3c8e776d 100644
--- a/sphinx/builders/__init__.py
+++ b/sphinx/builders/__init__.py
@@ -11,7 +11,6 @@
import warnings
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
@@ -37,7 +36,8 @@ try:
except ImportError:
multiprocessing = None
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterable, List, Sequence, Set, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/builders/_epub_base.py b/sphinx/builders/_epub_base.py
index 39c288cf5..a2fa6d576 100644
--- a/sphinx/builders/_epub_base.py
+++ b/sphinx/builders/_epub_base.py
@@ -13,7 +13,6 @@ import os
import re
from collections import namedtuple
from os import path
-from typing import TYPE_CHECKING
from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile
from docutils import nodes
@@ -36,7 +35,8 @@ except ImportError:
except ImportError:
Image = None
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/applehelp.py b/sphinx/builders/applehelp.py
index 3e289effc..79d57210c 100644
--- a/sphinx/builders/applehelp.py
+++ b/sphinx/builders/applehelp.py
@@ -16,7 +16,6 @@ import plistlib
import shlex
import subprocess
from os import path, environ
-from typing import TYPE_CHECKING
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.config import string_classes
@@ -29,7 +28,8 @@ from sphinx.util.matching import Matcher
from sphinx.util.osutil import copyfile, ensuredir, make_filename
from sphinx.util.pycompat import htmlescape
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py
index fe88b5aaf..011aa6ebe 100644
--- a/sphinx/builders/changes.py
+++ b/sphinx/builders/changes.py
@@ -11,7 +11,6 @@
import codecs
from os import path
-from typing import TYPE_CHECKING
from six import iteritems
@@ -25,7 +24,8 @@ from sphinx.util.fileutil import copy_asset_file
from sphinx.util.osutil import ensuredir, os_path
from sphinx.util.pycompat import htmlescape
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/devhelp.py b/sphinx/builders/devhelp.py
index f1511b564..3d35b7496 100644
--- a/sphinx/builders/devhelp.py
+++ b/sphinx/builders/devhelp.py
@@ -15,7 +15,6 @@ from __future__ import absolute_import
import gzip
import re
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
@@ -31,7 +30,8 @@ try:
except ImportError:
import lxml.etree as etree # type: ignore
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/dummy.py b/sphinx/builders/dummy.py
index cc23c6e2b..805924290 100644
--- a/sphinx/builders/dummy.py
+++ b/sphinx/builders/dummy.py
@@ -9,12 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
from sphinx.builders import Builder
from sphinx.locale import __
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Set # NOQA
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/epub3.py b/sphinx/builders/epub3.py
index 995f5a6dc..752a3990d 100644
--- a/sphinx/builders/epub3.py
+++ b/sphinx/builders/epub3.py
@@ -12,7 +12,6 @@
from collections import namedtuple
from os import path
-from typing import TYPE_CHECKING
from sphinx import package_dir
from sphinx.builders import _epub_base
@@ -23,7 +22,8 @@ from sphinx.util.fileutil import copy_asset_file
from sphinx.util.i18n import format_date
from sphinx.util.osutil import make_filename
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterable, List # NOQA
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py
index 584463b4f..c8fbb9c32 100644
--- a/sphinx/builders/gettext.py
+++ b/sphinx/builders/gettext.py
@@ -16,7 +16,6 @@ from collections import defaultdict, OrderedDict
from datetime import datetime, tzinfo, timedelta
from os import path, walk, getenv
from time import time
-from typing import TYPE_CHECKING
from uuid import uuid4
from six import iteritems, StringIO
@@ -31,7 +30,8 @@ from sphinx.util.nodes import extract_messages, traverse_translatable_index
from sphinx.util.osutil import safe_relpath, ensuredir, canon_path
from sphinx.util.tags import Tags
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, DefaultDict, Dict, Iterable, List, Set, Tuple # NOQA
from docutils import nodes # NOQA
from sphinx.util.i18n import CatalogInfo # NOQA
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index 017f58620..fc295329a 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -16,7 +16,6 @@ import sys
import warnings
from hashlib import md5
from os import path
-from typing import TYPE_CHECKING
import docutils
from docutils import nodes
@@ -52,7 +51,8 @@ from sphinx.util.osutil import SEP, os_path, relative_uri, ensuredir, \
movefile, copyfile
from sphinx.writers.html import HTMLWriter, HTMLTranslator
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, IO, Iterable, Iterator, List, Type, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/builders/htmlhelp.py b/sphinx/builders/htmlhelp.py
index 8f7cd7734..8d4ded246 100644
--- a/sphinx/builders/htmlhelp.py
+++ b/sphinx/builders/htmlhelp.py
@@ -14,7 +14,6 @@ from __future__ import print_function
import codecs
import os
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
@@ -26,7 +25,8 @@ from sphinx.util import logging
from sphinx.util.osutil import make_filename
from sphinx.util.pycompat import htmlescape
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, IO, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py
index 0be57f013..e0ce9f235 100644
--- a/sphinx/builders/latex.py
+++ b/sphinx/builders/latex.py
@@ -11,7 +11,6 @@
import os
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.frontend import OptionParser
@@ -33,7 +32,8 @@ from sphinx.util.nodes import inline_all_toctrees
from sphinx.util.osutil import SEP, make_filename
from sphinx.writers.latex import LaTeXWriter, LaTeXTranslator
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterable, List, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py
index 50768c5b9..22e7f01ad 100644
--- a/sphinx/builders/linkcheck.py
+++ b/sphinx/builders/linkcheck.py
@@ -14,7 +14,6 @@ import re
import socket
import threading
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from requests.exceptions import HTTPError
@@ -39,7 +38,8 @@ from sphinx.util.console import ( # type: ignore
)
from sphinx.util.requests import is_ssl_error
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Set, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.util.requests.requests import Response # NOQA
diff --git a/sphinx/builders/manpage.py b/sphinx/builders/manpage.py
index e1bbcffa8..32bd9950b 100644
--- a/sphinx/builders/manpage.py
+++ b/sphinx/builders/manpage.py
@@ -10,7 +10,6 @@
"""
from os import path
-from typing import TYPE_CHECKING
from docutils.frontend import OptionParser
from docutils.io import FileOutput
@@ -26,7 +25,8 @@ from sphinx.util.nodes import inline_all_toctrees
from sphinx.util.osutil import make_filename
from sphinx.writers.manpage import ManualPageWriter, ManualPageTranslator
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Set, Union # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/qthelp.py b/sphinx/builders/qthelp.py
index a5b320c9e..0539e18de 100644
--- a/sphinx/builders/qthelp.py
+++ b/sphinx/builders/qthelp.py
@@ -14,7 +14,6 @@ import os
import posixpath
import re
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from six import text_type
@@ -28,7 +27,8 @@ from sphinx.util import force_decode, logging
from sphinx.util.osutil import make_filename
from sphinx.util.pycompat import htmlescape
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/texinfo.py b/sphinx/builders/texinfo.py
index f43ff9ec0..2a022158f 100644
--- a/sphinx/builders/texinfo.py
+++ b/sphinx/builders/texinfo.py
@@ -11,7 +11,6 @@
import os
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.frontend import OptionParser
@@ -31,7 +30,8 @@ from sphinx.util.nodes import inline_all_toctrees
from sphinx.util.osutil import SEP, make_filename
from sphinx.writers.texinfo import TexinfoWriter, TexinfoTranslator
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from sphinx.application import Sphinx # NOQA
from typing import Any, Dict, Iterable, List, Tuple, Union # NOQA
diff --git a/sphinx/builders/text.py b/sphinx/builders/text.py
index 0be9f3795..81209d165 100644
--- a/sphinx/builders/text.py
+++ b/sphinx/builders/text.py
@@ -11,7 +11,6 @@
import codecs
from os import path
-from typing import TYPE_CHECKING
from docutils.io import StringOutput
@@ -21,7 +20,8 @@ from sphinx.util import logging
from sphinx.util.osutil import ensuredir, os_path
from sphinx.writers.text import TextWriter, TextTranslator
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterator, Set, Tuple # NOQA
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/websupport.py b/sphinx/builders/websupport.py
index b7a45c570..1fe9e2001 100644
--- a/sphinx/builders/websupport.py
+++ b/sphinx/builders/websupport.py
@@ -9,9 +9,8 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/builders/xml.py b/sphinx/builders/xml.py
index 933e86374..6198532c9 100644
--- a/sphinx/builders/xml.py
+++ b/sphinx/builders/xml.py
@@ -11,7 +11,6 @@
import codecs
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.io import StringOutput
@@ -23,7 +22,8 @@ from sphinx.util import logging
from sphinx.util.osutil import ensuredir, os_path
from sphinx.writers.xml import XMLWriter, PseudoXMLWriter
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterator, Set # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/cmd/build.py b/sphinx/cmd/build.py
index f64bfabb6..865e272cf 100644
--- a/sphinx/cmd/build.py
+++ b/sphinx/cmd/build.py
@@ -16,7 +16,6 @@ import multiprocessing
import os
import sys
import traceback
-from typing import TYPE_CHECKING
from docutils.utils import SystemMessage
from six import text_type, binary_type
@@ -31,7 +30,8 @@ from sphinx.util.console import red, nocolor, color_terminal # type: ignore
from sphinx.util.docutils import docutils_namespace, patch_docutils
from sphinx.util.pycompat import terminal_safe
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, IO, List, Union # NOQA
diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py
index 22dbe1e0f..d6c7fa22a 100644
--- a/sphinx/cmd/quickstart.py
+++ b/sphinx/cmd/quickstart.py
@@ -20,7 +20,6 @@ import time
from collections import OrderedDict
from io import open
from os import path
-from typing import TYPE_CHECKING
# try to import readline, unix specific enhancement
try:
@@ -47,7 +46,8 @@ from sphinx.util.console import ( # type: ignore
from sphinx.util.osutil import ensuredir, make_filename
from sphinx.util.template import SphinxRenderer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, List, Pattern, Union # NOQA
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
diff --git a/sphinx/cmdline.py b/sphinx/cmdline.py
index 3ad16d041..10835d2e7 100644
--- a/sphinx/cmdline.py
+++ b/sphinx/cmdline.py
@@ -13,12 +13,12 @@ from __future__ import print_function
import sys
import warnings
-from typing import TYPE_CHECKING
from sphinx.cmd import build
from sphinx.deprecation import RemovedInSphinx30Warning
-if TYPE_CHECKING:
+if False:
+ # For type annotation
import argparse # NOQA
from typing import Any, IO, List, Union # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/config.py b/sphinx/config.py
index 46487619b..df4a8f184 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -13,7 +13,7 @@ import re
import traceback
from collections import OrderedDict
from os import path, getenv
-from typing import TYPE_CHECKING, Any, NamedTuple, Union
+from typing import Any, NamedTuple, Union
from six import PY2, PY3, iteritems, string_types, binary_type, text_type, integer_types
@@ -24,7 +24,8 @@ from sphinx.util.i18n import format_date
from sphinx.util.osutil import cd
from sphinx.util.pycompat import execfile_, NoneType
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.util.tags import Tags # NOQA
diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py
index d1aa4a6bd..dc51810d3 100644
--- a/sphinx/directives/__init__.py
+++ b/sphinx/directives/__init__.py
@@ -10,7 +10,6 @@
"""
import re
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives, roles
@@ -30,7 +29,8 @@ from sphinx.directives.patches import ( # noqa
Figure, Meta
)
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index e26e93cd2..8690fca0f 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -10,7 +10,6 @@
import codecs
import sys
from difflib import unified_diff
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -23,7 +22,8 @@ from sphinx.util import logging
from sphinx.util import parselinenos
from sphinx.util.nodes import set_source_info
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py
index 5272b6881..252e6522a 100644
--- a/sphinx/directives/other.py
+++ b/sphinx/directives/other.py
@@ -7,8 +7,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from docutils.parsers.rst import Directive, directives
from docutils.parsers.rst.directives.admonitions import BaseAdmonition
@@ -24,7 +22,8 @@ from sphinx.util.matching import patfilter
from sphinx.util.nodes import explicit_title_re, set_source_info, \
process_index_entry
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py
index 8407c9981..14f0ca17e 100644
--- a/sphinx/directives/patches.py
+++ b/sphinx/directives/patches.py
@@ -7,8 +7,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from docutils.parsers.rst import directives
from docutils.parsers.rst.directives import images, html, tables
@@ -16,7 +14,8 @@ from docutils.parsers.rst.directives import images, html, tables
from sphinx import addnodes
from sphinx.util.nodes import set_source_info
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/domains/__init__.py b/sphinx/domains/__init__.py
index bcb67d337..009d3bfdb 100644
--- a/sphinx/domains/__init__.py
+++ b/sphinx/domains/__init__.py
@@ -11,14 +11,14 @@
"""
import copy
-from typing import TYPE_CHECKING
from six import iteritems
from sphinx.errors import SphinxError
from sphinx.locale import _
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterable, List, Tuple, Type, Union # NOQA
from docutils import nodes # NOQA
from docutils.parsers.rst.states import Inliner # NOQA
diff --git a/sphinx/domains/c.py b/sphinx/domains/c.py
index 709395710..50e9b2e5e 100644
--- a/sphinx/domains/c.py
+++ b/sphinx/domains/c.py
@@ -11,7 +11,6 @@
import re
import string
-from typing import TYPE_CHECKING
from docutils import nodes
@@ -23,7 +22,8 @@ from sphinx.roles import XRefRole
from sphinx.util.docfields import Field, TypedField
from sphinx.util.nodes import make_refnode
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterator, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index cbf3bb39c..f4234b0db 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -11,7 +11,6 @@
import re
from copy import deepcopy
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -29,7 +28,8 @@ from sphinx.util.nodes import make_refnode
from sphinx.util.pycompat import UnicodeMixin
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterator, List, Match, Pattern, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
diff --git a/sphinx/domains/javascript.py b/sphinx/domains/javascript.py
index 7f21adf65..0ea6114d6 100644
--- a/sphinx/domains/javascript.py
+++ b/sphinx/domains/javascript.py
@@ -9,8 +9,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -23,7 +21,8 @@ from sphinx.roles import XRefRole
from sphinx.util.docfields import Field, GroupedField, TypedField
from sphinx.util.nodes import make_refnode
-if TYPE_CHECKING:
+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
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py
index 62c0b1df4..312b509a0 100644
--- a/sphinx/domains/python.py
+++ b/sphinx/domains/python.py
@@ -10,7 +10,6 @@
"""
import re
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -26,7 +25,8 @@ from sphinx.util import logging
from sphinx.util.docfields import Field, GroupedField, TypedField
from sphinx.util.nodes import make_refnode
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterable, Iterator, List, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
diff --git a/sphinx/domains/rst.py b/sphinx/domains/rst.py
index ef3a94d6a..fcb461484 100644
--- a/sphinx/domains/rst.py
+++ b/sphinx/domains/rst.py
@@ -10,7 +10,6 @@
"""
import re
-from typing import TYPE_CHECKING
from six import iteritems
@@ -21,7 +20,8 @@ from sphinx.locale import _
from sphinx.roles import XRefRole
from sphinx.util.nodes import make_refnode
-if TYPE_CHECKING:
+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
diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py
index 4658c9995..307108b00 100644
--- a/sphinx/domains/std.py
+++ b/sphinx/domains/std.py
@@ -12,7 +12,6 @@
import re
import unicodedata
from copy import copy
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -27,7 +26,8 @@ from sphinx.roles import XRefRole
from sphinx.util import ws_re, logging, docname_join
from sphinx.util.nodes import clean_astext, make_refnode
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterator, List, Tuple, Type, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py
index 136953616..461fc1227 100644
--- a/sphinx/environment/__init__.py
+++ b/sphinx/environment/__init__.py
@@ -18,7 +18,6 @@ import warnings
from collections import defaultdict
from copy import copy
from os import path
-from typing import TYPE_CHECKING
from docutils.frontend import OptionParser
from docutils.utils import Reporter, get_source_line
@@ -42,7 +41,8 @@ from sphinx.util.nodes import is_translatable
from sphinx.util.osutil import SEP, ensuredir
from sphinx.util.websupport import is_commentable
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, IO, Iterator, List, Optional, Pattern, Set, Tuple, Type, Union, Generator # NOQA
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/environment/adapters/asset.py b/sphinx/environment/adapters/asset.py
index 179fbcb12..91f2cf8eb 100644
--- a/sphinx/environment/adapters/asset.py
+++ b/sphinx/environment/adapters/asset.py
@@ -9,9 +9,8 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/environment/adapters/indexentries.py b/sphinx/environment/adapters/indexentries.py
index 3e1f47c6e..7c31fc3d5 100644
--- a/sphinx/environment/adapters/indexentries.py
+++ b/sphinx/environment/adapters/indexentries.py
@@ -12,14 +12,14 @@ import bisect
import re
import unicodedata
from itertools import groupby
-from typing import TYPE_CHECKING
from six import text_type, iteritems
from sphinx.locale import _, __
from sphinx.util import split_into, logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Pattern, List, Tuple # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/environment/adapters/toctree.py b/sphinx/environment/adapters/toctree.py
index 920c4b502..f1261bcdc 100644
--- a/sphinx/environment/adapters/toctree.py
+++ b/sphinx/environment/adapters/toctree.py
@@ -9,8 +9,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from six import iteritems
@@ -19,7 +17,8 @@ from sphinx.locale import __
from sphinx.util import url_re, logging
from sphinx.util.nodes import clean_astext, process_only_nodes
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/environment/collectors/__init__.py b/sphinx/environment/collectors/__init__.py
index 066f8a490..9d9f5347c 100644
--- a/sphinx/environment/collectors/__init__.py
+++ b/sphinx/environment/collectors/__init__.py
@@ -9,11 +9,10 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from six import itervalues
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, List, Set # NOQA
from docutils import nodes # NOQA
from sphinx.sphinx import Sphinx # NOQA
diff --git a/sphinx/environment/collectors/asset.py b/sphinx/environment/collectors/asset.py
index 06af528c1..70faf108c 100644
--- a/sphinx/environment/collectors/asset.py
+++ b/sphinx/environment/collectors/asset.py
@@ -12,7 +12,6 @@
import os
from glob import glob
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.utils import relative_path
@@ -25,7 +24,8 @@ from sphinx.util import logging
from sphinx.util.i18n import get_image_filename_for_language, search_image_for_language
from sphinx.util.images import guess_mimetype
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, List, Set, Tuple # NOQA
from docutils import nodes # NOQA
from sphinx.sphinx import Sphinx # NOQA
diff --git a/sphinx/environment/collectors/dependencies.py b/sphinx/environment/collectors/dependencies.py
index 453db9681..de0b7c080 100644
--- a/sphinx/environment/collectors/dependencies.py
+++ b/sphinx/environment/collectors/dependencies.py
@@ -10,14 +10,14 @@
"""
from os import path
-from typing import TYPE_CHECKING
from docutils.utils import relative_path
from sphinx.environment.collectors import EnvironmentCollector
from sphinx.util.osutil import getcwd, fs_encoding
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, Set # NOQA
from docutils import nodes # NOQA
from sphinx.sphinx import Sphinx # NOQA
diff --git a/sphinx/environment/collectors/indexentries.py b/sphinx/environment/collectors/indexentries.py
index dc47d6f0c..a9ba897d0 100644
--- a/sphinx/environment/collectors/indexentries.py
+++ b/sphinx/environment/collectors/indexentries.py
@@ -9,15 +9,14 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from six import text_type
from sphinx import addnodes
from sphinx.environment.collectors import EnvironmentCollector
from sphinx.util import split_index_msg, logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, Set # NOQA
from docutils import nodes # NOQA
from sphinx.applicatin import Sphinx # NOQA
diff --git a/sphinx/environment/collectors/metadata.py b/sphinx/environment/collectors/metadata.py
index b1f223ff9..7d54d2fe6 100644
--- a/sphinx/environment/collectors/metadata.py
+++ b/sphinx/environment/collectors/metadata.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from sphinx.environment.collectors import EnvironmentCollector
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, Set # NOQA
from docutils import nodes # NOQA
from sphinx.sphinx import Sphinx # NOQA
diff --git a/sphinx/environment/collectors/title.py b/sphinx/environment/collectors/title.py
index 96bf4db32..eb23b975f 100644
--- a/sphinx/environment/collectors/title.py
+++ b/sphinx/environment/collectors/title.py
@@ -9,14 +9,13 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from sphinx.environment.collectors import EnvironmentCollector
from sphinx.transforms import SphinxContentsFilter
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, Set # NOQA
from docutils import nodes # NOQA
from sphinx.sphinx import Sphinx # NOQA
diff --git a/sphinx/environment/collectors/toctree.py b/sphinx/environment/collectors/toctree.py
index 5ff03da39..245433002 100644
--- a/sphinx/environment/collectors/toctree.py
+++ b/sphinx/environment/collectors/toctree.py
@@ -9,8 +9,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from six import iteritems
@@ -21,7 +19,8 @@ from sphinx.locale import __
from sphinx.transforms import SphinxContentsFilter
from sphinx.util import url_re, logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
diff --git a/sphinx/errors.py b/sphinx/errors.py
index 7ac0d9c85..7652e93cb 100644
--- a/sphinx/errors.py
+++ b/sphinx/errors.py
@@ -10,9 +10,8 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/events.py b/sphinx/events.py
index 9d74e778f..fb62d1776 100644
--- a/sphinx/events.py
+++ b/sphinx/events.py
@@ -13,14 +13,14 @@
from __future__ import print_function
from collections import OrderedDict, defaultdict
-from typing import TYPE_CHECKING
from six import itervalues
from sphinx.errors import ExtensionError
from sphinx.locale import __
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, List # NOQA
diff --git a/sphinx/ext/apidoc.py b/sphinx/ext/apidoc.py
index 17c95ece2..056835863 100644
--- a/sphinx/ext/apidoc.py
+++ b/sphinx/ext/apidoc.py
@@ -24,7 +24,6 @@ import os
import sys
from fnmatch import fnmatch
from os import path
-from typing import TYPE_CHECKING
from six import binary_type
@@ -35,7 +34,8 @@ from sphinx.locale import __
from sphinx.util import rst
from sphinx.util.osutil import FileAvoidWrite, ensuredir, walk
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, List, Tuple # NOQA
# automodule options
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index b5fef0df6..132116d55 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -15,7 +15,6 @@ import inspect
import re
import sys
import warnings
-from typing import TYPE_CHECKING
from docutils.statemachine import ViewList
from six import iteritems, itervalues, text_type, class_types, string_types
@@ -35,7 +34,8 @@ from sphinx.util.inspect import Signature, isdescriptor, safe_getmembers, \
safe_getattr, object_description, is_builtin_class_method, \
isenumattribute, isclassmethod, isstaticmethod, getdoc
-if TYPE_CHECKING:
+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
diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py
index 0e19516ad..77b3f7aaf 100644
--- a/sphinx/ext/autodoc/directive.py
+++ b/sphinx/ext/autodoc/directive.py
@@ -7,8 +7,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.statemachine import ViewList
@@ -19,7 +17,8 @@ from sphinx.util import logging
from sphinx.util.docutils import switch_source_input
from sphinx.util.nodes import nested_parse_with_titles
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Set, Type # NOQA
from docutils.statemachine import State, StateMachine, StringList # NOQA
from docutils.utils import Reporter # NOQA
diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py
index fec8c1936..2cc8cbd1f 100644
--- a/sphinx/ext/autodoc/importer.py
+++ b/sphinx/ext/autodoc/importer.py
@@ -15,14 +15,14 @@ import traceback
import warnings
from collections import namedtuple
from types import FunctionType, MethodType, ModuleType
-from typing import TYPE_CHECKING
from six import PY2
from sphinx.util import logging
from sphinx.util.inspect import isenumclass, safe_getattr
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Generator, List, Optional # NOQA
logger = logging.getLogger(__name__)
diff --git a/sphinx/ext/autodoc/inspector.py b/sphinx/ext/autodoc/inspector.py
index 19f47b221..6e07c9547 100644
--- a/sphinx/ext/autodoc/inspector.py
+++ b/sphinx/ext/autodoc/inspector.py
@@ -11,14 +11,14 @@
import typing
import warnings
-from typing import TYPE_CHECKING
from six import StringIO, string_types
from sphinx.deprecation import RemovedInSphinx20Warning
from sphinx.util.inspect import object_description
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Tuple # NOQA
diff --git a/sphinx/ext/autosectionlabel.py b/sphinx/ext/autosectionlabel.py
index ad039483f..5713828a4 100644
--- a/sphinx/ext/autosectionlabel.py
+++ b/sphinx/ext/autosectionlabel.py
@@ -9,22 +9,21 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.nodes import clean_astext
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
logger = logging.getLogger(__name__)
-if TYPE_CHECKING:
+if False:
# For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py
index b9cde483e..d9cf47535 100644
--- a/sphinx/ext/autosummary/__init__.py
+++ b/sphinx/ext/autosummary/__init__.py
@@ -60,7 +60,6 @@ import re
import sys
import warnings
from types import ModuleType
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -81,7 +80,8 @@ from sphinx.pycode import ModuleAnalyzer, PycodeError
from sphinx.util import import_object, rst, logging
from sphinx.util.docutils import NullReporter, new_document
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple, Type, Union # NOQA
from docutils.utils import Inliner # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py
index 1db34c03a..4c9175a5d 100644
--- a/sphinx/ext/autosummary/generate.py
+++ b/sphinx/ext/autosummary/generate.py
@@ -26,7 +26,6 @@ import os
import pydoc
import re
import sys
-from typing import TYPE_CHECKING
from jinja2 import FileSystemLoader, TemplateNotFound
from jinja2.sandbox import SandboxedEnvironment
@@ -42,7 +41,8 @@ from sphinx.util.inspect import safe_getattr
from sphinx.util.osutil import ensuredir
from sphinx.util.rst import escape as rst_escape
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Tuple, List # NOQA
from jinja2 import BaseLoader # NOQA
from sphinx import addnodes # NOQA
diff --git a/sphinx/ext/coverage.py b/sphinx/ext/coverage.py
index f473a607e..351108faa 100644
--- a/sphinx/ext/coverage.py
+++ b/sphinx/ext/coverage.py
@@ -14,7 +14,6 @@ import glob
import inspect
import re
from os import path
-from typing import TYPE_CHECKING
from six import iteritems
from six.moves import cPickle as pickle
@@ -25,7 +24,8 @@ from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.inspect import safe_getattr
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, IO, List, Pattern, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py
index 3b57c3469..255a38f6d 100644
--- a/sphinx/ext/doctest.py
+++ b/sphinx/ext/doctest.py
@@ -17,7 +17,6 @@ import re
import sys
import time
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -33,7 +32,8 @@ from sphinx.util.console import bold # type: ignore
from sphinx.util.nodes import set_source_info
from sphinx.util.osutil import fs_encoding
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, IO, Iterable, List, Optional, Sequence, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py
index daff7f103..bc348f4e1 100644
--- a/sphinx/ext/graphviz.py
+++ b/sphinx/ext/graphviz.py
@@ -16,7 +16,6 @@ import re
from hashlib import sha1
from os import path
from subprocess import Popen, PIPE
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -30,7 +29,8 @@ from sphinx.util import logging
from sphinx.util.i18n import search_image_for_language
from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py
index 57527fada..16042ac3f 100644
--- a/sphinx/ext/ifconfig.py
+++ b/sphinx/ext/ifconfig.py
@@ -20,15 +20,14 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from docutils.parsers.rst import Directive
import sphinx
from sphinx.util.nodes import set_source_info
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/ext/imgconverter.py b/sphinx/ext/imgconverter.py
index 45aef39fa..8546593a7 100644
--- a/sphinx/ext/imgconverter.py
+++ b/sphinx/ext/imgconverter.py
@@ -9,7 +9,6 @@
:license: BSD, see LICENSE for details.
"""
import subprocess
-from typing import TYPE_CHECKING
from sphinx.errors import ExtensionError
from sphinx.locale import __
@@ -17,7 +16,8 @@ from sphinx.transforms.post_transforms.images import ImageConverter
from sphinx.util import logging
from sphinx.util.osutil import ENOENT, EPIPE, EINVAL
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/ext/imgmath.py b/sphinx/ext/imgmath.py
index 463fdda88..a1faf2c1b 100644
--- a/sphinx/ext/imgmath.py
+++ b/sphinx/ext/imgmath.py
@@ -17,7 +17,6 @@ import tempfile
from hashlib import sha1
from os import path
from subprocess import Popen, PIPE
-from typing import TYPE_CHECKING
from docutils import nodes
from six import text_type
@@ -32,7 +31,8 @@ from sphinx.util.osutil import ensuredir, ENOENT, cd
from sphinx.util.png import read_png_depth, write_png_depth
from sphinx.util.pycompat import sys_encoding
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py
index 4420dfe05..6f8256662 100644
--- a/sphinx/ext/inheritance_diagram.py
+++ b/sphinx/ext/inheritance_diagram.py
@@ -40,7 +40,6 @@ import inspect
import re
import sys
from hashlib import md5
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -53,7 +52,8 @@ from sphinx.ext.graphviz import render_dot_html, render_dot_latex, \
from sphinx.pycode import ModuleAnalyzer
from sphinx.util import force_decode
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple, Dict, Optional # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py
index c9878e3ef..af219d16a 100644
--- a/sphinx/ext/intersphinx.py
+++ b/sphinx/ext/intersphinx.py
@@ -32,7 +32,6 @@ import sys
import time
import warnings
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.utils import relative_path
@@ -46,7 +45,8 @@ from sphinx.locale import _, __
from sphinx.util import requests, logging
from sphinx.util.inventory import InventoryFile
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, IO, List, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/ext/linkcode.py b/sphinx/ext/linkcode.py
index 8467bffd5..af45f32fa 100644
--- a/sphinx/ext/linkcode.py
+++ b/sphinx/ext/linkcode.py
@@ -9,8 +9,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
import sphinx
@@ -18,7 +16,8 @@ from sphinx import addnodes
from sphinx.errors import SphinxError
from sphinx.locale import _
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Set # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py
index 54c300d67..939247638 100644
--- a/sphinx/ext/mathbase.py
+++ b/sphinx/ext/mathbase.py
@@ -9,8 +9,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes, utils
from docutils.nodes import make_id
from docutils.parsers.rst import Directive, directives
@@ -22,7 +20,8 @@ from sphinx.roles import XRefRole
from sphinx.util import logging
from sphinx.util.nodes import make_refnode, set_source_info
-if TYPE_CHECKING:
+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
@@ -87,6 +86,7 @@ class MathDomain(Domain):
newnode['target'] = target
return newnode
else:
+ # TODO: perhaps use rather a sphinx-core provided prefix here?
node_id = make_id('equation-%s' % target)
if env.config.math_numfig and env.config.numfig:
if docname in env.toc_fignumbers:
diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py
index cd7831946..b968f5948 100644
--- a/sphinx/ext/napoleon/__init__.py
+++ b/sphinx/ext/napoleon/__init__.py
@@ -10,7 +10,6 @@
"""
import sys
-from typing import TYPE_CHECKING
from six import PY2, iteritems
@@ -18,7 +17,8 @@ import sphinx
from sphinx.application import Sphinx
from sphinx.ext.napoleon.docstring import GoogleDocstring, NumpyDocstring
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List # NOQA
diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py
index d632748ec..530cec203 100644
--- a/sphinx/ext/napoleon/docstring.py
+++ b/sphinx/ext/napoleon/docstring.py
@@ -15,7 +15,6 @@ import collections
import inspect
import re
from functools import partial
-from typing import TYPE_CHECKING
from six import string_types, u
from six.moves import range
@@ -23,7 +22,8 @@ from six.moves import range
from sphinx.ext.napoleon.iterators import modify_iter
from sphinx.util.pycompat import UnicodeMixin
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, List, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config as SphinxConfig # NOQA
diff --git a/sphinx/ext/napoleon/iterators.py b/sphinx/ext/napoleon/iterators.py
index 72be60c82..b4bba8863 100644
--- a/sphinx/ext/napoleon/iterators.py
+++ b/sphinx/ext/napoleon/iterators.py
@@ -12,9 +12,9 @@
"""
import collections
-from typing import TYPE_CHECKING
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Iterable # NOQA
diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py
index 1f3bc71da..c7ef16b51 100644
--- a/sphinx/ext/todo.py
+++ b/sphinx/ext/todo.py
@@ -12,8 +12,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
@@ -26,7 +24,8 @@ from sphinx.util import logging
from sphinx.util.nodes import set_source_info
from sphinx.util.texescape import tex_escape_map
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterable, List # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/ext/viewcode.py b/sphinx/ext/viewcode.py
index 0836ed56e..d20ad78d5 100644
--- a/sphinx/ext/viewcode.py
+++ b/sphinx/ext/viewcode.py
@@ -10,7 +10,6 @@
"""
import traceback
-from typing import TYPE_CHECKING
from docutils import nodes
from six import iteritems, text_type
@@ -22,7 +21,8 @@ from sphinx.pycode import ModuleAnalyzer
from sphinx.util import get_full_modname, logging, status_iterator
from sphinx.util.nodes import make_refnode
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterable, Iterator, Set, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/extension.py b/sphinx/extension.py
index 7acec4588..732ea327c 100644
--- a/sphinx/extension.py
+++ b/sphinx/extension.py
@@ -9,15 +9,14 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from six import iteritems
from sphinx.errors import VersionRequirementError
from sphinx.locale import __
from sphinx.util import logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index 372ab7c43..7d5956570 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -9,8 +9,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from pygments import highlight
from pygments.filters import ErrorToken
from pygments.formatters import HtmlFormatter, LatexFormatter
@@ -29,7 +27,8 @@ from sphinx.util import logging
from sphinx.util.pycompat import htmlescape
from sphinx.util.texescape import tex_hl_escape_map_new
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict # NOQA
from pygments.formatter import Formatter # NOQA
diff --git a/sphinx/io.py b/sphinx/io.py
index b7b70ef9b..826da1812 100644
--- a/sphinx/io.py
+++ b/sphinx/io.py
@@ -10,7 +10,6 @@
"""
import codecs
import re
-from typing import TYPE_CHECKING
from docutils.core import Publisher
from docutils.io import FileInput, NullOutput
@@ -35,7 +34,8 @@ from sphinx.transforms.i18n import (
from sphinx.util import logging
from sphinx.util.docutils import LoggingReporter
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple, Union # NOQA
from docutils import nodes # NOQA
from docutils.io import Input # NOQA
@@ -306,7 +306,7 @@ def read_doc(app, env, filename):
source_class=SphinxDummySourceClass,
destination=NullOutput())
pub.set_components(None, 'restructuredtext', None)
- pub.process_programmatic_settings(None, env.settings, None) # type: ignore
+ pub.process_programmatic_settings(None, env.settings, None)
pub.set_source(source, filename)
pub.publish()
return pub.document
diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py
index 0cf95d882..24dd0e0fd 100644
--- a/sphinx/jinja2glue.py
+++ b/sphinx/jinja2glue.py
@@ -11,7 +11,7 @@
from os import path
from pprint import pformat
-from typing import TYPE_CHECKING, Any, Callable, Iterator, Tuple # NOQA
+from typing import Any, Callable, Iterator, Tuple # NOQA
from jinja2 import FileSystemLoader, BaseLoader, TemplateNotFound, \
contextfunction
@@ -22,7 +22,8 @@ from six import string_types
from sphinx.application import TemplateBridge
from sphinx.util.osutil import mtimes_of_files
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, List, Iterator, Tuple, Union # NOQA
from jinja2.environment import Environment # NOQA
from sphinx.builders import Builder # NOQA
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py
index afd31f276..b0bf0ead1 100644
--- a/sphinx/locale/__init__.py
+++ b/sphinx/locale/__init__.py
@@ -14,14 +14,14 @@ import locale
import warnings
from collections import defaultdict
from gettext import NullTranslations
-from typing import TYPE_CHECKING
from six import text_type
from six.moves import UserString
from sphinx.deprecation import RemovedInSphinx30Warning
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterator, List, Tuple # NOQA
diff --git a/sphinx/make_mode.py b/sphinx/make_mode.py
index b293ba54a..23fb4ce64 100644
--- a/sphinx/make_mode.py
+++ b/sphinx/make_mode.py
@@ -20,14 +20,14 @@ import os
import subprocess
import sys
from os import path
-from typing import TYPE_CHECKING
import sphinx
from sphinx.cmd.build import build_main
from sphinx.util.console import color_terminal, nocolor, bold, blue # type: ignore
from sphinx.util.osutil import cd, rmtree
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import List # NOQA
proj_name = os.getenv('SPHINXPROJ', '<project>')
@@ -101,22 +101,34 @@ class Make(object):
# type: () -> int
if self.run_generic_build('latex') > 0:
return 1
- with cd(self.builddir_join('latex')):
- return subprocess.call([self.makecmd, 'all-pdf'])
+ try:
+ with cd(self.builddir_join('latex')):
+ return subprocess.call([self.makecmd, 'all-pdf'])
+ except OSError:
+ print('Error: Failed to run: %s' % self.makecmd)
+ return 1
def build_latexpdfja(self):
# type: () -> int
if self.run_generic_build('latex') > 0:
return 1
- with cd(self.builddir_join('latex')):
- return subprocess.call([self.makecmd, 'all-pdf-ja'])
+ try:
+ with cd(self.builddir_join('latex')):
+ return subprocess.call([self.makecmd, 'all-pdf-ja'])
+ except OSError:
+ print('Error: Failed to run: %s' % self.makecmd)
+ return 1
def build_info(self):
# type: () -> int
if self.run_generic_build('texinfo') > 0:
return 1
- with cd(self.builddir_join('texinfo')):
- return subprocess.call([self.makecmd, 'info'])
+ try:
+ with cd(self.builddir_join('texinfo')):
+ return subprocess.call([self.makecmd, 'info'])
+ except OSError:
+ print('Error: Failed to run: %s' % self.makecmd)
+ return 1
def build_gettext(self):
# type: () -> int
diff --git a/sphinx/parsers.py b/sphinx/parsers.py
index 2da0ef63b..db62e7154 100644
--- a/sphinx/parsers.py
+++ b/sphinx/parsers.py
@@ -9,15 +9,14 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
import docutils.parsers
import docutils.parsers.rst
from docutils.parsers.rst import states
from docutils.statemachine import StringList
from docutils.transforms.universal import SmartQuotes
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Type # NOQA
from docutils import nodes # NOQA
from docutils.transforms import Transform # NOQA
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py
index 096845eba..04353e805 100644
--- a/sphinx/pycode/__init__.py
+++ b/sphinx/pycode/__init__.py
@@ -10,15 +10,14 @@
"""
from __future__ import print_function
-from typing import TYPE_CHECKING
-
from six import iteritems, BytesIO, StringIO
from sphinx.errors import PycodeError
from sphinx.pycode.parser import Parser
from sphinx.util import get_module_source, detect_encoding
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, IO, List, Tuple # NOQA
diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py
index f21d1b77d..8f6615b54 100644
--- a/sphinx/pycode/parser.py
+++ b/sphinx/pycode/parser.py
@@ -15,11 +15,11 @@ import re
import tokenize
from token import NAME, NEWLINE, INDENT, DEDENT, NUMBER, OP, STRING
from tokenize import COMMENT, NL
-from typing import TYPE_CHECKING
from six import PY2, text_type
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, IO, List, Tuple # NOQA
comment_re = re.compile(u'^\\s*#: ?(.*)\r?\n?$')
diff --git a/sphinx/registry.py b/sphinx/registry.py
index 722dfa959..0b95f16b9 100644
--- a/sphinx/registry.py
+++ b/sphinx/registry.py
@@ -14,7 +14,6 @@ import traceback
import warnings
from inspect import isclass
from types import MethodType
-from typing import TYPE_CHECKING
from docutils.parsers.rst import Directive
from pkg_resources import iter_entry_points
@@ -32,12 +31,13 @@ from sphinx.util import logging
from sphinx.util.console import bold # type: ignore
from sphinx.util.docutils import directive_helper
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterator, List, Tuple, Type, Union # NOQA
from docutils import nodes # NOQA
from docutils.io import Input # NOQA
from docutils.parsers import Parser # NOQA
- from docutils.transform import Transform # NOQA
+ from docutils.transforms import Transform # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.domains import Domain, Index # NOQA
diff --git a/sphinx/roles.py b/sphinx/roles.py
index a5142e8e9..2971c8fc3 100644
--- a/sphinx/roles.py
+++ b/sphinx/roles.py
@@ -10,7 +10,6 @@
"""
import re
-from typing import TYPE_CHECKING
from docutils import nodes, utils
from six import iteritems
@@ -22,7 +21,8 @@ from sphinx.util import ws_re
from sphinx.util.nodes import split_explicit_title, process_index_entry, \
set_role_source_info
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple, Type # NOQA
from docutils.parsers.rst.states import Inliner # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py
index 58d98cdeb..fc55a2a45 100644
--- a/sphinx/search/__init__.py
+++ b/sphinx/search/__init__.py
@@ -10,7 +10,6 @@
"""
import re
from os import path
-from typing import TYPE_CHECKING
from six import iteritems, itervalues, text_type, string_types
from six.moves import cPickle as pickle
@@ -22,7 +21,8 @@ from sphinx.util import jsdump, rpartition
from sphinx.util.pycompat import htmlescape
from sphinx.search.jssplitter import splitter_code
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, IO, Iterable, List, Tuple, Type, Set # NOQA
from docutils import nodes # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/search/da.py b/sphinx/search/da.py
index 186219cca..26ac428fe 100644
--- a/sphinx/search/da.py
+++ b/sphinx/search/da.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/de.py b/sphinx/search/de.py
index 186e4ab08..00e36354b 100644
--- a/sphinx/search/de.py
+++ b/sphinx/search/de.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/en.py b/sphinx/search/en.py
index 8ba2b852d..fe9b7d8da 100644
--- a/sphinx/search/en.py
+++ b/sphinx/search/en.py
@@ -9,12 +9,11 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage
from sphinx.util.stemmer import get_stemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict # NOQA
english_stopwords = set(u"""
diff --git a/sphinx/search/es.py b/sphinx/search/es.py
index 48783feff..971d0c149 100644
--- a/sphinx/search/es.py
+++ b/sphinx/search/es.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/fi.py b/sphinx/search/fi.py
index 039035bd6..b2b47781e 100644
--- a/sphinx/search/fi.py
+++ b/sphinx/search/fi.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/fr.py b/sphinx/search/fr.py
index 0c42843ec..9976c1ca7 100644
--- a/sphinx/search/fr.py
+++ b/sphinx/search/fr.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/hu.py b/sphinx/search/hu.py
index c2abbd677..9cdee61fe 100644
--- a/sphinx/search/hu.py
+++ b/sphinx/search/hu.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/it.py b/sphinx/search/it.py
index 1a26c4488..db86e386e 100644
--- a/sphinx/search/it.py
+++ b/sphinx/search/it.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py
index b400590f2..0cdc14a11 100644
--- a/sphinx/search/ja.py
+++ b/sphinx/search/ja.py
@@ -20,7 +20,6 @@
import os
import re
import sys
-from typing import TYPE_CHECKING
from six import iteritems, PY3
@@ -40,7 +39,8 @@ from sphinx.errors import SphinxError, ExtensionError
from sphinx.search import SearchLanguage
from sphinx.util import import_object
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List # NOQA
diff --git a/sphinx/search/nl.py b/sphinx/search/nl.py
index fc26bbd2f..49003d2d1 100644
--- a/sphinx/search/nl.py
+++ b/sphinx/search/nl.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/no.py b/sphinx/search/no.py
index d582cd02c..7f5a73858 100644
--- a/sphinx/search/no.py
+++ b/sphinx/search/no.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/pt.py b/sphinx/search/pt.py
index 1fd0b65c8..44c7e2118 100644
--- a/sphinx/search/pt.py
+++ b/sphinx/search/pt.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/ro.py b/sphinx/search/ro.py
index 0d9bc31ab..b4beced2d 100644
--- a/sphinx/search/ro.py
+++ b/sphinx/search/ro.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, Set # NOQA
js_stemmer = u"""
diff --git a/sphinx/search/ru.py b/sphinx/search/ru.py
index 085569f20..b628b9866 100644
--- a/sphinx/search/ru.py
+++ b/sphinx/search/ru.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
diff --git a/sphinx/search/sv.py b/sphinx/search/sv.py
index f6d40feed..953ae94b5 100644
--- a/sphinx/search/sv.py
+++ b/sphinx/search/sv.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage, parse_stop_word
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any
swedish_stopwords = parse_stop_word(u'''
diff --git a/sphinx/search/tr.py b/sphinx/search/tr.py
index e97779641..4ce42dd76 100644
--- a/sphinx/search/tr.py
+++ b/sphinx/search/tr.py
@@ -9,13 +9,12 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from sphinx.search import SearchLanguage
import snowballstemmer
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, Set # NOQA
js_stemmer = u"""
diff --git a/sphinx/search/zh.py b/sphinx/search/zh.py
index 1ec2628e9..2301e1103 100644
--- a/sphinx/search/zh.py
+++ b/sphinx/search/zh.py
@@ -11,7 +11,6 @@
import os
import re
-from typing import TYPE_CHECKING
from sphinx.search import SearchLanguage
from sphinx.util.stemmer import get_stemmer
@@ -22,7 +21,8 @@ try:
except ImportError:
JIEBA = False
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, List # NOQA
english_stopwords = set(u"""
diff --git a/sphinx/setup_command.py b/sphinx/setup_command.py
index af31b923e..37fc2d042 100644
--- a/sphinx/setup_command.py
+++ b/sphinx/setup_command.py
@@ -17,7 +17,6 @@ import os
import sys
from distutils.cmd import Command
from distutils.errors import DistutilsOptionError, DistutilsExecError # type: ignore
-from typing import TYPE_CHECKING
from six import StringIO, string_types
@@ -27,7 +26,8 @@ from sphinx.util.console import nocolor, color_terminal
from sphinx.util.docutils import docutils_namespace, patch_docutils
from sphinx.util.osutil import abspath
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, List, Tuple # NOQA
diff --git a/sphinx/testing/fixtures.py b/sphinx/testing/fixtures.py
index b4b4adf1e..76ed154fd 100644
--- a/sphinx/testing/fixtures.py
+++ b/sphinx/testing/fixtures.py
@@ -15,14 +15,14 @@ import subprocess
import sys
from collections import namedtuple
from tempfile import gettempdir
-from typing import TYPE_CHECKING
import pytest
from six import StringIO, string_types
from . import util
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Union # NOQA
diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py
index 1a9ea3bc9..e55007d80 100644
--- a/sphinx/testing/util.py
+++ b/sphinx/testing/util.py
@@ -12,7 +12,6 @@ import os
import re
import sys
import warnings
-from typing import TYPE_CHECKING
from xml.etree import ElementTree
from docutils import nodes
@@ -25,7 +24,9 @@ from sphinx.ext.autodoc import AutoDirective
from sphinx.pycode import ModuleAnalyzer
from sphinx.testing.path import path
-if TYPE_CHECKING:
+if False:
+ # For type annotation
+ from typing import List # NOQA
from typing import Any, Dict, Generator, IO, List, Pattern # NOQA
diff --git a/sphinx/theming.py b/sphinx/theming.py
index 5944a3751..7287f7fc4 100644
--- a/sphinx/theming.py
+++ b/sphinx/theming.py
@@ -14,7 +14,6 @@ import shutil
import tempfile
import warnings
from os import path
-from typing import TYPE_CHECKING
from zipfile import ZipFile
import pkg_resources
@@ -30,7 +29,8 @@ from sphinx.util.osutil import ensuredir
logger = logging.getLogger(__name__)
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Iterator, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py
index fcce60feb..d82b02149 100644
--- a/sphinx/transforms/__init__.py
+++ b/sphinx/transforms/__init__.py
@@ -10,7 +10,6 @@
"""
import re
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.transforms import Transform, Transformer
@@ -26,7 +25,8 @@ from sphinx.util.docutils import new_document
from sphinx.util.i18n import format_date
from sphinx.util.nodes import apply_source_workaround, is_smartquotable
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Generator, List # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
@@ -376,7 +376,7 @@ class SphinxSmartQuotes(SmartQuotes, SphinxTransform):
return False
# confirm selected language supports smart_quotes or not
- language = self.env.settings['language_code'] # type: ignore
+ language = self.env.settings['language_code']
for tag in normalize_language_tag(language):
if tag in smartchars.quotes:
return True
diff --git a/sphinx/transforms/compact_bullet_list.py b/sphinx/transforms/compact_bullet_list.py
index 6e4bb0929..0121dd12f 100644
--- a/sphinx/transforms/compact_bullet_list.py
+++ b/sphinx/transforms/compact_bullet_list.py
@@ -9,14 +9,13 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from sphinx import addnodes
from sphinx.transforms import SphinxTransform
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import List # NOQA
diff --git a/sphinx/transforms/i18n.py b/sphinx/transforms/i18n.py
index 386c5ae39..156c5ac4c 100644
--- a/sphinx/transforms/i18n.py
+++ b/sphinx/transforms/i18n.py
@@ -10,7 +10,6 @@
"""
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.io import StringInput
@@ -28,7 +27,8 @@ from sphinx.util.nodes import (
)
from sphinx.util.pycompat import indent
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/transforms/post_transforms/__init__.py b/sphinx/transforms/post_transforms/__init__.py
index 952b972f7..7c71e8585 100644
--- a/sphinx/transforms/post_transforms/__init__.py
+++ b/sphinx/transforms/post_transforms/__init__.py
@@ -10,7 +10,6 @@
"""
import warnings
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.utils import get_source_line
@@ -23,7 +22,8 @@ from sphinx.transforms import SphinxTransform
from sphinx.util import logging
from sphinx.util.nodes import process_only_nodes
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.domains import Domain # NOQA
diff --git a/sphinx/transforms/post_transforms/images.py b/sphinx/transforms/post_transforms/images.py
index 0e29fdead..7e73332ff 100644
--- a/sphinx/transforms/post_transforms/images.py
+++ b/sphinx/transforms/post_transforms/images.py
@@ -12,7 +12,6 @@
import os
from hashlib import sha1
from math import ceil
-from typing import TYPE_CHECKING
from docutils import nodes
from six import text_type
@@ -24,7 +23,8 @@ from sphinx.util import logging, requests
from sphinx.util.images import guess_mimetype, get_image_extension, parse_data_uri
from sphinx.util.osutil import ensuredir, movefile
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index 6ed9196f7..6a28432e3 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -24,7 +24,6 @@ from collections import deque
from datetime import datetime
from os import path
from time import mktime, strptime
-from typing import TYPE_CHECKING
from docutils.utils import relative_path
from six import text_type, binary_type, itervalues
@@ -49,7 +48,8 @@ from sphinx.util.nodes import ( # noqa
caption_ref_re)
from sphinx.util.matching import patfilter # noqa
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Pattern, Sequence, Set, Tuple, Union # NOQA
diff --git a/sphinx/util/compat.py b/sphinx/util/compat.py
index c6578c810..43ced1f5e 100644
--- a/sphinx/util/compat.py
+++ b/sphinx/util/compat.py
@@ -13,14 +13,14 @@ from __future__ import absolute_import
import sys
import warnings
-from typing import TYPE_CHECKING
from six import string_types, iteritems
from sphinx.deprecation import RemovedInSphinx30Warning
from sphinx.util import import_object
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict # NOQA
from sphinx.application import Sphinx # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index cf9604f09..7663feb1e 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -8,12 +8,10 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
import os
import re
import sys
-from typing import TYPE_CHECKING
try:
# check if colorama is installed to support color on Windows
@@ -21,7 +19,8 @@ try:
except ImportError:
colorama = None
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict # NOQA
diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py
index dc5a16b68..202616337 100644
--- a/sphinx/util/docfields.py
+++ b/sphinx/util/docfields.py
@@ -11,13 +11,12 @@
"""
from __future__ import absolute_import
-from typing import TYPE_CHECKING
-
from docutils import nodes
from sphinx import addnodes
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from sphinx.domains import Domain # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/util/docstrings.py b/sphinx/util/docstrings.py
index bc0b2d301..bc4b96a56 100644
--- a/sphinx/util/docstrings.py
+++ b/sphinx/util/docstrings.py
@@ -8,12 +8,11 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
import sys
-from typing import TYPE_CHECKING
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import List # NOQA
diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py
index 2af5a1cb7..949bec3b4 100644
--- a/sphinx/util/docutils.py
+++ b/sphinx/util/docutils.py
@@ -16,7 +16,6 @@ import warnings
from contextlib import contextmanager
from copy import copy
from distutils.version import LooseVersion
-from typing import TYPE_CHECKING
import docutils
from docutils import nodes
@@ -33,7 +32,8 @@ from sphinx.util import logging
logger = logging.getLogger(__name__)
report_re = re.compile('^(.+?:(?:\\d+)?): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) ')
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Generator, Iterator, List, Set, Tuple # NOQA
from docutils.statemachine import State, ViewList # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/util/fileutil.py b/sphinx/util/fileutil.py
index 9b9725810..7caf40275 100644
--- a/sphinx/util/fileutil.py
+++ b/sphinx/util/fileutil.py
@@ -13,13 +13,13 @@ from __future__ import absolute_import
import codecs
import os
import posixpath
-from typing import TYPE_CHECKING
from docutils.utils import relative_path
from sphinx.util.osutil import copyfile, ensuredir, walk
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Callable, Dict, Union # NOQA
from sphinx.util.matching import Matcher # NOQA
from sphinx.util.template import BaseRenderer # NOQA
diff --git a/sphinx/util/i18n.py b/sphinx/util/i18n.py
index 0ed25818d..9b6270bdf 100644
--- a/sphinx/util/i18n.py
+++ b/sphinx/util/i18n.py
@@ -8,8 +8,6 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
-
import gettext
import io
import os
@@ -17,7 +15,6 @@ import re
from collections import namedtuple
from datetime import datetime
from os import path
-from typing import TYPE_CHECKING
import babel.dates
from babel.messages.mofile import write_mo
@@ -30,7 +27,8 @@ from sphinx.util.osutil import SEP, walk
logger = logging.getLogger(__name__)
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Callable, List, Set # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/util/images.py b/sphinx/util/images.py
index b3bad1769..9abe748e4 100644
--- a/sphinx/util/images.py
+++ b/sphinx/util/images.py
@@ -14,7 +14,7 @@ import base64
import imghdr
from collections import OrderedDict
from os import path
-from typing import TYPE_CHECKING, NamedTuple
+from typing import NamedTuple
import imagesize
from six import PY3, BytesIO, iteritems
@@ -27,7 +27,8 @@ except ImportError:
except ImportError:
Image = None
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict, IO, List, Tuple # NOQA
if PY3:
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index ab20787c1..6b404790c 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -15,14 +15,14 @@ import re
import sys
import typing
from collections import OrderedDict
-from typing import TYPE_CHECKING
from six import PY2, PY3, StringIO, binary_type, string_types, itervalues
from six.moves import builtins
from sphinx.util import force_decode
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, List, Tuple, Type # NOQA
memory_address_re = re.compile(r' at 0x[0-9a-f]{8,16}(?=>)', re.IGNORECASE)
diff --git a/sphinx/util/inventory.py b/sphinx/util/inventory.py
index 4ed12e2da..ed4e55bc2 100644
--- a/sphinx/util/inventory.py
+++ b/sphinx/util/inventory.py
@@ -8,18 +8,16 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
-
import os
import re
import zlib
-from typing import TYPE_CHECKING
from six import PY3
from sphinx.util import logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Callable, Dict, IO, Iterator, Tuple # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA
diff --git a/sphinx/util/jsdump.py b/sphinx/util/jsdump.py
index 2226475f6..6776691cf 100644
--- a/sphinx/util/jsdump.py
+++ b/sphinx/util/jsdump.py
@@ -9,16 +9,15 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
import re
-from typing import TYPE_CHECKING
from six import iteritems, integer_types, string_types
from sphinx.util.pycompat import u
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, IO, List, Match, Union # NOQA
_str_re = re.compile(r'"(\\\\|\\"|[^"])*"')
diff --git a/sphinx/util/jsonimpl.py b/sphinx/util/jsonimpl.py
index 29e6a1a88..fbaa72978 100644
--- a/sphinx/util/jsonimpl.py
+++ b/sphinx/util/jsonimpl.py
@@ -8,15 +8,14 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
import json
-from typing import TYPE_CHECKING
from six import text_type
from six.moves import UserString
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, IO # NOQA
diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py
index 2ab4f705e..1ac4fb327 100644
--- a/sphinx/util/logging.py
+++ b/sphinx/util/logging.py
@@ -14,7 +14,6 @@ import logging
import logging.handlers
from collections import defaultdict
from contextlib import contextmanager
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.utils import get_source_line
@@ -23,7 +22,8 @@ from six import PY2, StringIO
from sphinx.errors import SphinxWarning
from sphinx.util.console import colorize
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Dict, Generator, IO, List, Tuple, Union # NOQA
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA
diff --git a/sphinx/util/matching.py b/sphinx/util/matching.py
index 08fb1680e..bddf84f5c 100644
--- a/sphinx/util/matching.py
+++ b/sphinx/util/matching.py
@@ -8,12 +8,11 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
import re
-from typing import TYPE_CHECKING
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Callable, Dict, List, Match, Pattern # NOQA
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index ef0872c64..bdda1369b 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -11,7 +11,6 @@
from __future__ import absolute_import
import re
-from typing import TYPE_CHECKING
from docutils import nodes
from six import text_type
@@ -20,7 +19,8 @@ from sphinx import addnodes
from sphinx.locale import __
from sphinx.util import logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Iterable, List, Set, Tuple, Union # NOQA
from sphinx.builders import Builder # NOQA
from sphinx.utils.tags import Tags # NOQA
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py
index d66ebe89e..21464bbe6 100644
--- a/sphinx/util/osutil.py
+++ b/sphinx/util/osutil.py
@@ -8,7 +8,6 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
from __future__ import print_function
import contextlib
@@ -23,13 +22,13 @@ import time
import warnings
from io import BytesIO, StringIO
from os import path
-from typing import TYPE_CHECKING
from six import PY2, PY3, text_type
from sphinx.deprecation import RemovedInSphinx30Warning
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Iterator, List, Tuple, Union # NOQA
# Errnos that we need.
diff --git a/sphinx/util/parallel.py b/sphinx/util/parallel.py
index be83a40ac..fe2577308 100644
--- a/sphinx/util/parallel.py
+++ b/sphinx/util/parallel.py
@@ -8,13 +8,11 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
import os
import time
import traceback
from math import sqrt
-from typing import TYPE_CHECKING
from six import iteritems
@@ -26,7 +24,8 @@ except ImportError:
from sphinx.errors import SphinxParallelError
from sphinx.util import logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, List, Sequence # NOQA
logger = logging.getLogger(__name__)
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py
index f1d044a73..8bcf7e4f8 100644
--- a/sphinx/util/pycompat.py
+++ b/sphinx/util/pycompat.py
@@ -8,15 +8,14 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
import codecs
import sys
-from typing import TYPE_CHECKING
from six import PY3, text_type, exec_
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Generator # NOQA
diff --git a/sphinx/util/requests.py b/sphinx/util/requests.py
index 2eab6e3ec..b6c0d1ab8 100644
--- a/sphinx/util/requests.py
+++ b/sphinx/util/requests.py
@@ -13,7 +13,6 @@ from __future__ import absolute_import
import warnings
from contextlib import contextmanager
-from typing import TYPE_CHECKING
import pkg_resources
import requests
@@ -76,7 +75,8 @@ else:
'install requests-2.4.1+.'
)
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Generator, Union # NOQA
from sphinx.config import Config # NOQA
diff --git a/sphinx/util/rst.py b/sphinx/util/rst.py
index 40f26c888..0e49f991a 100644
--- a/sphinx/util/rst.py
+++ b/sphinx/util/rst.py
@@ -12,7 +12,6 @@ from __future__ import absolute_import
import re
from contextlib import contextmanager
-from typing import TYPE_CHECKING
from docutils.parsers.rst import roles
from docutils.parsers.rst.languages import en as english
@@ -21,10 +20,11 @@ from docutils.utils import Reporter
from sphinx.locale import __
from sphinx.util import logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Generator # NOQA
-symbols_re = re.compile(r'([!--/:-@\[-`{-~])') # symbols without dot(0x2e)
+symbols_re = re.compile(r'([!-\-/:-@\[-`{-~])') # symbols without dot(0x2e)
logger = logging.getLogger(__name__)
diff --git a/sphinx/util/smartypants.py b/sphinx/util/smartypants.py
index c34d4daad..03fc1816c 100644
--- a/sphinx/util/smartypants.py
+++ b/sphinx/util/smartypants.py
@@ -28,13 +28,12 @@
from __future__ import absolute_import, unicode_literals
import re
-from typing import TYPE_CHECKING
from docutils.utils import smartquotes
from sphinx.util.docutils import __version_info__ as docutils_version
-if TYPE_CHECKING:
+if False: # For type annotation
from typing import Iterable, Iterator, Tuple # NOQA
diff --git a/sphinx/util/tags.py b/sphinx/util/tags.py
index b31b42270..43a351f65 100644
--- a/sphinx/util/tags.py
+++ b/sphinx/util/tags.py
@@ -6,9 +6,6 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
-
-from typing import TYPE_CHECKING
# (ab)use the Jinja parser for parsing our boolean expressions
from jinja2 import nodes
@@ -17,7 +14,8 @@ from jinja2.parser import Parser
env = Environment()
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Iterator, List # NOQA
diff --git a/sphinx/util/template.py b/sphinx/util/template.py
index 90354e6f2..5a415d329 100644
--- a/sphinx/util/template.py
+++ b/sphinx/util/template.py
@@ -8,10 +8,8 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from __future__ import absolute_import
import os
-from typing import TYPE_CHECKING
from jinja2.sandbox import SandboxedEnvironment
@@ -19,7 +17,8 @@ from sphinx import package_dir
from sphinx.jinja2glue import SphinxFileSystemLoader
from sphinx.locale import get_translator
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Dict # NOQA
from jinja2.loaders import BaseLoader # NOQA
diff --git a/sphinx/versioning.py b/sphinx/versioning.py
index d9bb8bd93..a855cb8fe 100644
--- a/sphinx/versioning.py
+++ b/sphinx/versioning.py
@@ -11,7 +11,6 @@
"""
from itertools import product
from operator import itemgetter
-from typing import TYPE_CHECKING
from uuid import uuid4
from six import iteritems
@@ -20,7 +19,8 @@ from six.moves import range, zip_longest
from sphinx.transforms import SphinxTransform
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Iterator # NOQA
from docutils import nodes # NOQA
diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py
index 26abdcd12..84dfb2aad 100644
--- a/sphinx/writers/html.py
+++ b/sphinx/writers/html.py
@@ -13,7 +13,6 @@ import copy
import os
import posixpath
import sys
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator
@@ -24,7 +23,8 @@ from sphinx.locale import admonitionlabels, _, __
from sphinx.util import logging
from sphinx.util.images import get_image_size
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
from sphinx.builders.html import StandaloneHTMLBuilder # NOQA
diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py
index b2acf8570..b38421db8 100644
--- a/sphinx/writers/html5.py
+++ b/sphinx/writers/html5.py
@@ -12,7 +12,6 @@
import os
import posixpath
import sys
-from typing import TYPE_CHECKING
from docutils import nodes
from docutils.writers.html5_polyglot import HTMLTranslator as BaseTranslator
@@ -23,7 +22,8 @@ from sphinx.locale import admonitionlabels, _, __
from sphinx.util import logging
from sphinx.util.images import get_image_size
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
from sphinx.builders.html import StandaloneHTMLBuilder # NOQA
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index 3cd5022b9..d87de1f19 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -16,7 +16,6 @@ import re
import sys
from collections import defaultdict
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes, writers
from docutils.writers.latex2e import Babel
@@ -33,7 +32,8 @@ from sphinx.util.nodes import clean_astext, traverse_parent
from sphinx.util.template import LaTeXRenderer
from sphinx.util.texescape import tex_escape_map, tex_replace_map
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterator, List, Pattern, Tuple, Set, Union # NOQA
from sphinx.builder import Builder # NOQA
@@ -1961,6 +1961,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
if id.startswith('index-'):
return
+ # equations also need no extra blank line nor hypertarget
+ # TODO: fix this dependency on mathbase extension internals
+ if id.startswith('equation-'):
+ return
+
# insert blank line, if the target follows a paragraph node
index = node.parent.index(node)
if index > 0 and isinstance(node.parent[index - 1], nodes.paragraph):
diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py
index f4431a3d6..76884cbf6 100644
--- a/sphinx/writers/manpage.py
+++ b/sphinx/writers/manpage.py
@@ -9,8 +9,6 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import nodes
from docutils.writers.manpage import (
MACRO_DEF,
@@ -24,7 +22,8 @@ from sphinx.locale import admonitionlabels, _, __
from sphinx.util import logging
from sphinx.util.i18n import format_date
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any # NOQA
from sphinx.builders import Builder # NOQA
diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py
index a69c7bd27..36c48131f 100644
--- a/sphinx/writers/texinfo.py
+++ b/sphinx/writers/texinfo.py
@@ -12,7 +12,6 @@
import re
import textwrap
from os import path
-from typing import TYPE_CHECKING
from docutils import nodes, writers
from six import itervalues
@@ -25,7 +24,8 @@ from sphinx.util import logging
from sphinx.util.i18n import format_date
from sphinx.writers.latex import collected_footnote
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, Iterator, List, Pattern, Set, Tuple, Union # NOQA
from sphinx.builders.texinfo import TexinfoBuilder # NOQA
diff --git a/sphinx/writers/text.py b/sphinx/writers/text.py
index 73a8f05b6..79789fcca 100644
--- a/sphinx/writers/text.py
+++ b/sphinx/writers/text.py
@@ -12,7 +12,6 @@ import os
import re
import textwrap
from itertools import groupby
-from typing import TYPE_CHECKING
from docutils import nodes, writers
from docutils.utils import column_width
@@ -22,7 +21,8 @@ from sphinx import addnodes
from sphinx.locale import admonitionlabels, _, __
from sphinx.util import logging
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Callable, Dict, List, Tuple, Union # NOQA
from sphinx.builders.text import TextBuilder # NOQA
diff --git a/sphinx/writers/xml.py b/sphinx/writers/xml.py
index b40d05ab7..f94fe847c 100644
--- a/sphinx/writers/xml.py
+++ b/sphinx/writers/xml.py
@@ -9,12 +9,11 @@
:license: BSD, see LICENSE for details.
"""
-from typing import TYPE_CHECKING
-
from docutils import writers
from docutils.writers.docutils_xml import Writer as BaseXMLWriter
-if TYPE_CHECKING:
+if False:
+ # For type annotation
from typing import Any, Tuple # NOQA
from sphinx.builders import Builder # NOQA