From f84917b8b12ccc3857efc4da8af11afbcf162994 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 7 Mar 2018 23:52:11 +0900 Subject: [PATCH 01/12] Fix #4716: Generation PDF file with TexLive on Windows, file not found error --- CHANGES | 1 + sphinx/make_mode.py | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 7bd94f54a..db553d40e 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,7 @@ Bugs fixed * pydomain: always strip parenthesis if empty (refs: #1042) * #4689: autosummary: unexpectedly strips docstrings containing "i.e." * #4701: viewcode: Misplaced ``
`` in viewcode html output +* #4716: Generation PDF file with TexLive on Windows, file not found error Testing -------- diff --git a/sphinx/make_mode.py b/sphinx/make_mode.py index 301baed49..c6b179885 100644 --- a/sphinx/make_mode.py +++ b/sphinx/make_mode.py @@ -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 From 711b8ecf70b613c8decabc9ab0d1895169f4b89c Mon Sep 17 00:00:00 2001 From: jfbu Date: Sun, 11 Mar 2018 11:36:16 +0100 Subject: [PATCH 02/12] Fix vertical space before equation in latex (closes: #4574) --- sphinx/writers/latex.py | 4 ++++ tests/roots/test-latex-equations/conf.py | 5 +++++ .../roots/test-latex-equations/equations.rst | 21 +++++++++++++++++++ .../expects/latex-equations.tex | 13 ++++++++++++ tests/test_build_latex.py | 10 +++++++++ 5 files changed, 53 insertions(+) create mode 100644 tests/roots/test-latex-equations/conf.py create mode 100644 tests/roots/test-latex-equations/equations.rst create mode 100644 tests/roots/test-latex-equations/expects/latex-equations.tex diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index ca410c4e9..bdb2a92b3 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1959,6 +1959,10 @@ class LaTeXTranslator(nodes.NodeVisitor): if id.startswith('index-'): return + # equations also need no extra blank line nor hypertarget + 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/tests/roots/test-latex-equations/conf.py b/tests/roots/test-latex-equations/conf.py new file mode 100644 index 000000000..6122e9212 --- /dev/null +++ b/tests/roots/test-latex-equations/conf.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +master_doc = 'equations' +extensions = ['sphinx.ext.imgmath'] + diff --git a/tests/roots/test-latex-equations/equations.rst b/tests/roots/test-latex-equations/equations.rst new file mode 100644 index 000000000..2eef2f2a4 --- /dev/null +++ b/tests/roots/test-latex-equations/equations.rst @@ -0,0 +1,21 @@ +test-latex-equation +=================== + +Equation without a label. + +.. math:: + + E = mc^2 + +Equation with label. + +.. math:: E = hv + :label: test + +Second equation without label. + +.. math:: + + c^2 = a^2 + b^2 + +Equation with label :eq:`test` is important. diff --git a/tests/roots/test-latex-equations/expects/latex-equations.tex b/tests/roots/test-latex-equations/expects/latex-equations.tex new file mode 100644 index 000000000..ce07a0128 --- /dev/null +++ b/tests/roots/test-latex-equations/expects/latex-equations.tex @@ -0,0 +1,13 @@ +Equation without a label. +\begin{equation*} +\begin{split}E = mc^2\end{split} +\end{equation*} +Equation with label. +\begin{equation}\label{equation:equations:test} +\begin{split}E = hv\end{split} +\end{equation} +Second equation without label. +\begin{equation*} +\begin{split}c^2 = a^2 + b^2\end{split} +\end{equation*} +Equation with label \eqref{equation:equations:test} is important. diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 4b02b7c54..602429a96 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -1134,6 +1134,16 @@ def test_latex_index(app, status, warning): assert '\n\\index{Einstein}\\index{relativity}\\ignorespaces \nand' in result +@pytest.mark.sphinx('latex', testroot='latex-equations') +def test_latex_equations(app, status, warning): + app.builder.build_all() + + result = (app.outdir / 'Python.tex').text(encoding='utf8') + expected = (app.srcdir / 'expects' / 'latex-equations.tex').text().strip() + + assert expected in result + + @pytest.mark.sphinx('latex', testroot='image-in-parsed-literal') def test_latex_image_in_parsed_literal(app, status, warning): app.builder.build_all() From c4e12ff01231d468682264b5d856aa78c39eeb19 Mon Sep 17 00:00:00 2001 From: jfbu Date: Mon, 12 Mar 2018 17:00:01 +0100 Subject: [PATCH 03/12] Add TODO notes modified: sphinx/ext/mathbase.py modified: sphinx/writers/latex.py --- sphinx/ext/mathbase.py | 1 + sphinx/writers/latex.py | 1 + 2 files changed, 2 insertions(+) diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py index 15218963f..513ddd62a 100644 --- a/sphinx/ext/mathbase.py +++ b/sphinx/ext/mathbase.py @@ -86,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/writers/latex.py b/sphinx/writers/latex.py index bdb2a92b3..1558a29d7 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1960,6 +1960,7 @@ class LaTeXTranslator(nodes.NodeVisitor): return # equations also need no extra blank line nor hypertarget + # TODO: fix this dependency on mathbase extension internals if id.startswith('equation-'): return From 2fd24f9129800c4970f973188484f5af3e4fa2a1 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 13 Mar 2018 23:00:30 +0900 Subject: [PATCH 04/12] Revert "Use typing.TYPE_CHECKING" This reverts commit f51b644f39ff53f14332eb8cd5019bbe8dc0e0e1. --- sphinx/util/compat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/util/compat.py b/sphinx/util/compat.py index 32ac11341..e01558077 100644 --- a/sphinx/util/compat.py +++ b/sphinx/util/compat.py @@ -11,10 +11,10 @@ from __future__ import absolute_import import sys -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 From 70a622b86c753f8b2b4c197e7baf8bdc64a2afc3 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 13 Mar 2018 23:01:11 +0900 Subject: [PATCH 05/12] Revert "Use typing.TYPE_CHECKING for typehints" This reverts commit a073e17537c2aacaac305feadea58d4473ec97f4. --- sphinx/addnodes.py | 5 ++--- sphinx/application.py | 4 ++-- sphinx/builders/__init__.py | 4 ++-- sphinx/builders/_epub_base.py | 4 ++-- sphinx/builders/applehelp.py | 4 ++-- sphinx/builders/changes.py | 4 ++-- sphinx/builders/devhelp.py | 4 ++-- sphinx/builders/dummy.py | 4 ++-- sphinx/builders/epub3.py | 4 ++-- sphinx/builders/gettext.py | 4 ++-- sphinx/builders/html.py | 4 ++-- sphinx/builders/htmlhelp.py | 4 ++-- sphinx/builders/latex.py | 4 ++-- sphinx/builders/linkcheck.py | 4 ++-- sphinx/builders/manpage.py | 4 ++-- sphinx/builders/qthelp.py | 4 ++-- sphinx/builders/texinfo.py | 4 ++-- sphinx/builders/text.py | 4 ++-- sphinx/builders/websupport.py | 5 ++--- sphinx/builders/xml.py | 4 ++-- sphinx/cmd/build.py | 4 ++-- sphinx/cmd/quickstart.py | 4 ++-- sphinx/cmdline.py | 4 ++-- sphinx/config.py | 5 +++-- sphinx/directives/__init__.py | 4 ++-- sphinx/directives/code.py | 4 ++-- sphinx/directives/other.py | 5 ++--- sphinx/directives/patches.py | 5 ++--- sphinx/domains/__init__.py | 4 ++-- sphinx/domains/c.py | 4 ++-- sphinx/domains/cpp.py | 4 ++-- sphinx/domains/javascript.py | 5 ++--- sphinx/domains/python.py | 4 ++-- sphinx/domains/rst.py | 4 ++-- sphinx/domains/std.py | 4 ++-- sphinx/environment/__init__.py | 4 ++-- sphinx/environment/adapters/asset.py | 5 ++--- sphinx/environment/adapters/indexentries.py | 4 ++-- sphinx/environment/adapters/toctree.py | 5 ++--- sphinx/environment/collectors/__init__.py | 5 ++--- sphinx/environment/collectors/asset.py | 4 ++-- sphinx/environment/collectors/dependencies.py | 4 ++-- sphinx/environment/collectors/indexentries.py | 5 ++--- sphinx/environment/collectors/metadata.py | 5 ++--- sphinx/environment/collectors/title.py | 5 ++--- sphinx/environment/collectors/toctree.py | 5 ++--- sphinx/errors.py | 5 ++--- sphinx/events.py | 4 ++-- sphinx/ext/apidoc.py | 4 ++-- sphinx/ext/autodoc/__init__.py | 4 ++-- sphinx/ext/autodoc/directive.py | 5 ++--- sphinx/ext/autodoc/importer.py | 4 ++-- sphinx/ext/autodoc/inspector.py | 4 ++-- sphinx/ext/autosectionlabel.py | 4 +--- sphinx/ext/autosummary/__init__.py | 4 ++-- sphinx/ext/autosummary/generate.py | 4 ++-- sphinx/ext/coverage.py | 4 ++-- sphinx/ext/doctest.py | 4 ++-- sphinx/ext/graphviz.py | 4 ++-- sphinx/ext/ifconfig.py | 5 ++--- sphinx/ext/imgconverter.py | 4 ++-- sphinx/ext/imgmath.py | 4 ++-- sphinx/ext/inheritance_diagram.py | 4 ++-- sphinx/ext/intersphinx.py | 4 ++-- sphinx/ext/linkcode.py | 5 ++--- sphinx/ext/mathbase.py | 5 ++--- sphinx/ext/napoleon/__init__.py | 4 ++-- sphinx/ext/napoleon/docstring.py | 4 ++-- sphinx/ext/napoleon/iterators.py | 4 ++-- sphinx/ext/pngmath.py | 4 ++-- sphinx/ext/todo.py | 5 ++--- sphinx/ext/viewcode.py | 4 ++-- sphinx/extension.py | 5 ++--- sphinx/highlighting.py | 5 ++--- sphinx/io.py | 4 ++-- sphinx/jinja2glue.py | 5 +++-- sphinx/locale/__init__.py | 4 ++-- sphinx/make_mode.py | 4 ++-- sphinx/parsers.py | 5 ++--- sphinx/pycode/__init__.py | 5 ++--- sphinx/pycode/parser.py | 4 ++-- sphinx/registry.py | 4 ++-- sphinx/roles.py | 4 ++-- sphinx/search/__init__.py | 4 ++-- sphinx/search/da.py | 2 -- sphinx/search/de.py | 2 -- sphinx/search/en.py | 5 ++--- sphinx/search/es.py | 2 -- sphinx/search/fi.py | 2 -- sphinx/search/fr.py | 2 -- sphinx/search/hu.py | 2 -- sphinx/search/it.py | 2 -- sphinx/search/ja.py | 4 ++-- sphinx/search/nl.py | 2 -- sphinx/search/no.py | 2 -- sphinx/search/pt.py | 2 -- sphinx/search/ro.py | 5 ++--- sphinx/search/ru.py | 2 -- sphinx/search/sv.py | 2 -- sphinx/search/tr.py | 5 ++--- sphinx/search/zh.py | 4 ++-- sphinx/setup_command.py | 4 ++-- sphinx/testing/fixtures.py | 3 +-- sphinx/testing/util.py | 3 +-- sphinx/theming.py | 4 ++-- sphinx/transforms/__init__.py | 4 ++-- sphinx/transforms/compact_bullet_list.py | 5 ++--- sphinx/transforms/i18n.py | 4 ++-- sphinx/transforms/post_transforms/__init__.py | 4 ++-- sphinx/transforms/post_transforms/images.py | 4 ++-- sphinx/util/__init__.py | 4 ++-- sphinx/util/console.py | 5 ++--- sphinx/util/docfields.py | 5 ++--- sphinx/util/docstrings.py | 5 ++--- sphinx/util/docutils.py | 4 ++-- sphinx/util/fileutil.py | 4 ++-- sphinx/util/i18n.py | 6 ++---- sphinx/util/images.py | 5 +++-- sphinx/util/inspect.py | 4 ++-- sphinx/util/inventory.py | 6 ++---- sphinx/util/jsdump.py | 5 ++--- sphinx/util/jsonimpl.py | 5 ++--- sphinx/util/logging.py | 4 ++-- sphinx/util/matching.py | 5 ++--- sphinx/util/nodes.py | 4 ++-- sphinx/util/osutil.py | 5 ++--- sphinx/util/parallel.py | 5 ++--- sphinx/util/pycompat.py | 5 ++--- sphinx/util/requests.py | 4 ++-- sphinx/util/rst.py | 4 ++-- sphinx/util/smartypants.py | 3 +-- sphinx/util/tags.py | 6 ++---- sphinx/util/template.py | 5 ++--- sphinx/versioning.py | 4 ++-- sphinx/writers/html.py | 4 ++-- sphinx/writers/html5.py | 4 ++-- sphinx/writers/latex.py | 4 ++-- sphinx/writers/manpage.py | 5 ++--- sphinx/writers/texinfo.py | 4 ++-- sphinx/writers/text.py | 4 ++-- sphinx/writers/xml.py | 5 ++--- 141 files changed, 257 insertions(+), 327 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 d943de81d..e59b736d4 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -18,7 +18,6 @@ import sys import warnings from collections import deque from os import path -from typing import TYPE_CHECKING from docutils import nodes from docutils.parsers.rst import directives, roles @@ -44,7 +43,8 @@ from sphinx.util.i18n import find_catalog_source_files from sphinx.util.osutil import ENOENT, 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.parsers import Parser # NOQA from docutils.transform import Transform # NOQA diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py index 2cd418ce3..5c4714e8f 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 @@ -33,7 +32,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 880326100..d44e7f2be 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 @@ -35,7 +34,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 d850581a8..d7974696c 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 @@ -28,7 +27,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 eb7bb1554..e8b6650cb 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 13e0beb28..96e06afdc 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 @@ -30,7 +29,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 e0f2a3dab..08d99a584 100644 --- a/sphinx/builders/dummy.py +++ b/sphinx/builders/dummy.py @@ -9,11 +9,11 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING from sphinx.builders import Builder -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 4f50e6505..008942a6a 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 @@ -22,7 +21,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 c33a0af40..579e05534 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 @@ -30,7 +29,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 6fef3e95f..183ffc017 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 a518582b4..ac32a42db 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 @@ -25,7 +24,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 55d1f99d1..c66d00d4f 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 c29c7ab06..8a10a4f2c 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 @@ -38,7 +37,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 fb7c15ac5..7a691ccf0 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 @@ -25,7 +24,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 089470cb6..776a2d142 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 @@ -27,7 +26,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 282689cef..c9a95a5fc 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 be33c0f9e..babb6ccee 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 @@ -20,7 +19,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 47a9f47d5..80d7723aa 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 @@ -22,7 +21,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 f01a4f941..c0c31ae67 100644 --- a/sphinx/cmd/build.py +++ b/sphinx/cmd/build.py @@ -10,9 +10,9 @@ """ import sys -from typing import TYPE_CHECKING -if TYPE_CHECKING: +if False: + # For type annotation from typing import List # NOQA diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py index 6a53b40f2..68718eeaf 100644 --- a/sphinx/cmd/quickstart.py +++ b/sphinx/cmd/quickstart.py @@ -19,7 +19,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: @@ -44,7 +43,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 2fa06a1ab..908da68d8 100644 --- a/sphinx/cmdline.py +++ b/sphinx/cmdline.py @@ -15,7 +15,6 @@ import multiprocessing import sys import traceback from os import path -from typing import TYPE_CHECKING from docutils.utils import SystemMessage from six import text_type, binary_type @@ -29,7 +28,8 @@ from sphinx.util.docutils import docutils_namespace, patch_docutils from sphinx.util.osutil import abspath, fs_encoding 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/config.py b/sphinx/config.py index 4f8bf969d..1f80ab366 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -12,7 +12,7 @@ import re import traceback 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 @@ -23,7 +23,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.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 91b8661b4..ae67cf4c6 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 @@ -22,7 +21,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 f04e429c2..e1ba1a279 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 @@ -23,7 +21,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 cb8ca31fa..c97340a81 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 # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/domains/__init__.py b/sphinx/domains/__init__.py index 3ae957fec..c68d37472 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 3f6a57815..f0c81db7b 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 1d52962e9..34385f9e6 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 037f1048b..734969fc1 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 73bc627e3..b0900b385 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 @@ -25,7 +24,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 f356704bf..c14eb180f 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 l_, _ 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 dff87d583..937760c45 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -11,7 +11,6 @@ import re import unicodedata -from typing import TYPE_CHECKING from docutils import nodes from docutils.parsers.rst import Directive, directives @@ -26,7 +25,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 94dd4187f..b31021caa 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 @@ -43,7 +42,8 @@ from sphinx.util.osutil import SEP, ensuredir from sphinx.util.parallel import ParallelTasks, parallel_available, make_chunks 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 db33a76a7..5ac8ff1d6 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 aeba0cc08..af5d85f23 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 @@ -18,7 +16,8 @@ from sphinx import addnodes 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 d33d8f665..2504a7ea4 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 @@ -24,7 +23,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 9555bcc71..dec5dbc75 100644 --- a/sphinx/environment/collectors/indexentries.py +++ b/sphinx/environment/collectors/indexentries.py @@ -9,13 +9,12 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - 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 e17c1db39..a7556eadd 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 @@ -20,7 +18,8 @@ from sphinx.environment.collectors import EnvironmentCollector 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 34c0cae33..eef1a157a 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 de9def1b9..097f61fc6 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 642bcf087..07c399f25 100644 --- a/sphinx/ext/apidoc.py +++ b/sphinx/ext/apidoc.py @@ -23,7 +23,6 @@ import os import sys from fnmatch import fnmatch from os import path -from typing import TYPE_CHECKING from six import binary_type @@ -32,7 +31,8 @@ from sphinx.cmd.quickstart import EXTENSIONS 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 8b9e90e57..89ca1f44c 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 857b6a91e..00a55c4c5 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 c01f5ef4b..6a3ff1422 100644 --- a/sphinx/ext/autosectionlabel.py +++ b/sphinx/ext/autosectionlabel.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from docutils import nodes from sphinx.util import logging @@ -18,7 +16,7 @@ from sphinx.util.nodes import clean_astext 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 73128a631..bf2c6fba0 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 @@ -80,7 +79,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 4c67831af..2818ab3c7 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -25,7 +25,6 @@ import os import pydoc import re import sys -from typing import TYPE_CHECKING from jinja2 import FileSystemLoader, TemplateNotFound from jinja2.sandbox import SandboxedEnvironment @@ -39,7 +38,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 73bd8d68e..6c9acfc7d 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 @@ -24,7 +23,8 @@ from sphinx.builders import Builder 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 b5123204d..2a889900d 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 a061ae885..08707b733 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 3c8d499e3..95f579e36 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 c35ac293a..5f9d7a1e2 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 77962c095..372f7baab 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 15218963f..24c10df3c 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 sphinx.application import Sphinx # NOQA diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py index 90374692c..b65f7f2a1 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 3c38f4141..b349c761f 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -14,7 +14,6 @@ import collections import inspect import re -from typing import TYPE_CHECKING from six import string_types, u from six.moves import range @@ -22,7 +21,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/pngmath.py b/sphinx/ext/pngmath.py index 96a3f02f4..ebb05e615 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -18,7 +18,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, Tuple # NOQA from sphinx.application import Sphinx # NOQA from sphinx.ext.mathbase import math as math_node, displaymath # NOQA diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py index 19378f6b5..fd3d5c062 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 b6a79a2ec..059aa5ef1 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 feb23b899..aa1157ec8 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 Dict # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index a14efd510..ac1d1118e 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 @@ -28,7 +26,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 113322e4b..c0b725884 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 @@ -34,7 +33,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 diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index 4dac0210a..cc935d577 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 # 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 c97624f72..e148f2c12 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -10,12 +10,12 @@ """ import gettext -from typing import TYPE_CHECKING from six import PY3, text_type from six.moves import UserString -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 301baed49..78df06107 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 import cmdline 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', '') diff --git a/sphinx/parsers.py b/sphinx/parsers.py index 57344ddb3..34822898f 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 04e63b728..de951a19f 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 c5d9be320..f15da664a 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 3ab3a69a0..28da0435e 100644 --- a/sphinx/registry.py +++ b/sphinx/registry.py @@ -11,7 +11,6 @@ from __future__ import print_function import traceback -from typing import TYPE_CHECKING from pkg_resources import iter_entry_points from six import iteritems, itervalues, string_types @@ -28,7 +27,8 @@ 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, Type, Union # NOQA from docutils import nodes # NOQA from docutils.io import Input # 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 2602aea3b..b3611152a 100644 --- a/sphinx/search/da.py +++ b/sphinx/search/da.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer diff --git a/sphinx/search/de.py b/sphinx/search/de.py index babb5bb9e..89cbe3de5 100644 --- a/sphinx/search/de.py +++ b/sphinx/search/de.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer 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 4fff081bb..2777811d8 100644 --- a/sphinx/search/es.py +++ b/sphinx/search/es.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer diff --git a/sphinx/search/fi.py b/sphinx/search/fi.py index 2f334ab24..ca63b0021 100644 --- a/sphinx/search/fi.py +++ b/sphinx/search/fi.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer diff --git a/sphinx/search/fr.py b/sphinx/search/fr.py index 7bd4abd31..615a47383 100644 --- a/sphinx/search/fr.py +++ b/sphinx/search/fr.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer diff --git a/sphinx/search/hu.py b/sphinx/search/hu.py index a1c4bab2c..85d15bac7 100644 --- a/sphinx/search/hu.py +++ b/sphinx/search/hu.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer diff --git a/sphinx/search/it.py b/sphinx/search/it.py index 7239fdef4..b613ce33c 100644 --- a/sphinx/search/it.py +++ b/sphinx/search/it.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer 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 5a13af1da..b2ab4e0f0 100644 --- a/sphinx/search/nl.py +++ b/sphinx/search/nl.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer diff --git a/sphinx/search/no.py b/sphinx/search/no.py index 0be73a26d..32f7b38c5 100644 --- a/sphinx/search/no.py +++ b/sphinx/search/no.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer diff --git a/sphinx/search/pt.py b/sphinx/search/pt.py index 2974d0424..ba9f2529b 100644 --- a/sphinx/search/pt.py +++ b/sphinx/search/pt.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer 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 7df587a25..8eb6c3dbb 100644 --- a/sphinx/search/ru.py +++ b/sphinx/search/ru.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer diff --git a/sphinx/search/sv.py b/sphinx/search/sv.py index c18c85487..64883381e 100644 --- a/sphinx/search/sv.py +++ b/sphinx/search/sv.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING - from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer 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 30553f827..1f160fec1 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 0ef072a46..be0037b70 100644 --- a/sphinx/testing/fixtures.py +++ b/sphinx/testing/fixtures.py @@ -15,14 +15,13 @@ 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: from typing import Dict, Union # NOQA diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py index a1e564015..60544cfa3 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,7 @@ from sphinx.ext.autodoc import AutoDirective from sphinx.pycode import ModuleAnalyzer from sphinx.testing.path import path -if TYPE_CHECKING: +if False: from typing import List # NOQA diff --git a/sphinx/theming.py b/sphinx/theming.py index bfd7e68ae..33c4c76be 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 12dc18694..d629ce878 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 sphinx.application import Sphinx # NOQA from sphinx.config import Config # NOQA from sphinx.domain.std import StandardDomain # NOQA 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 b4b3f8388..bb85c76bd 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 c107f832e..b8f4b9a5d 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 @@ -23,7 +22,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 3cd429b3c..dda3fb04c 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -23,7 +23,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 @@ -47,7 +46,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/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 f41adf67f..2f952d7cc 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 a1ae3b31e..38f275824 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -15,7 +15,6 @@ import types from contextlib import contextmanager from copy import copy from distutils.version import LooseVersion -from typing import TYPE_CHECKING import docutils from docutils import nodes @@ -31,7 +30,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, 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 c11f59381..4989de1c9 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 @@ -29,7 +26,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 2f4395482..dd2f2a9e2 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 042c3c554..e8427fd84 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 6b0afd633..09db0028f 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 9b1e81490..f439c515e 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 pairindextypes 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 ce68fb8b3..af87caf9a 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 @@ -22,11 +21,11 @@ import sys import time from io import BytesIO, StringIO from os import path -from typing import TYPE_CHECKING from six import PY2, PY3, text_type -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 e2e68f6d0..a406e0044 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 @@ -20,7 +19,8 @@ from docutils.utils import Reporter 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) diff --git a/sphinx/util/smartypants.py b/sphinx/util/smartypants.py index 97b4e243e..bca901b18 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 f50f6cb4c..bd0928775 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 d9bc1e5dd..0fc4a7bea 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 4a265594e..21d7626ef 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 ca410c4e9..b425f79e6 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 diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index f647a7cf9..38954ca81 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 3767ba3fc..cce269479 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 12103042f..5e870efa2 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 From f2a23b761ee6ea53f9d1d2835ac209955bab414a Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 5 Feb 2018 14:38:35 +0900 Subject: [PATCH 06/12] Fix #4543: test for autodoc fails with python 3.5.3 --- tests/test_autodoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 4025beaa9..5505891b2 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -949,7 +949,7 @@ def test_partialmethod(): ' Update state of cell to *state*.', ' ', ] - if sys.version_info < (3, 5): + if sys.version_info < (3, 5, 4): expected = '\n'.join(expected).replace(' -> None', '').split('\n') assert call_autodoc('class', 'target.partialmethod.Cell') == expected From b9d6e0a211151a7ecbe3ed3a7effec2738fa7115 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 13 Mar 2018 23:18:58 +0900 Subject: [PATCH 07/12] Update CHANGES --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 793136812..9a28bf5f2 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,7 @@ Bugs fixed * #4701: viewcode: Misplaced ``
`` in viewcode html output * #4444: Don't require numfig to use :numref: on sections * #4727: Option clash for package textcomp +* #4725: Sphinx does not work with python 3.5.0 and 3.5.1 Testing -------- From 786c3e0c20b515687c16d2ef34cd50eff4c3e742 Mon Sep 17 00:00:00 2001 From: guoci Date: Tue, 13 Mar 2018 11:49:44 -0400 Subject: [PATCH 08/12] prevent raising of FutureWarning in regex. --- sphinx/util/rst.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/util/rst.py b/sphinx/util/rst.py index e2e68f6d0..aaab956a1 100644 --- a/sphinx/util/rst.py +++ b/sphinx/util/rst.py @@ -23,7 +23,7 @@ from sphinx.util import logging if TYPE_CHECKING: 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__) From 40446f594936376166070b34bb03027a3bf4be83 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 14 Mar 2018 01:03:02 +0900 Subject: [PATCH 09/12] Fix mypy violations --- sphinx/io.py | 2 +- sphinx/transforms/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/io.py b/sphinx/io.py index c0b725884..8f1da22bd 100644 --- a/sphinx/io.py +++ b/sphinx/io.py @@ -289,7 +289,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/transforms/__init__.py b/sphinx/transforms/__init__.py index d629ce878..a2e92223d 100644 --- a/sphinx/transforms/__init__.py +++ b/sphinx/transforms/__init__.py @@ -374,7 +374,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 From 6a6fcb5d869b5bd149fa0cbedebeb25f10926cf0 Mon Sep 17 00:00:00 2001 From: cocoatomo Date: Wed, 14 Mar 2018 02:07:53 +0900 Subject: [PATCH 10/12] Fix module name --- sphinx/application.py | 2 +- sphinx/registry.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/application.py b/sphinx/application.py index e59b736d4..8b8d02952 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -47,7 +47,7 @@ if False: # For type annotation from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Tuple, Type, Union # 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/registry.py b/sphinx/registry.py index 28da0435e..cc012b3f7 100644 --- a/sphinx/registry.py +++ b/sphinx/registry.py @@ -33,7 +33,7 @@ if False: 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 From bccdc7f02d1ee89212651f577551bc41e608ce02 Mon Sep 17 00:00:00 2001 From: jfbu Date: Thu, 15 Mar 2018 10:30:21 +0100 Subject: [PATCH 11/12] Update CHANGES after PR #4729 modified: CHANGES --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 5e3957b76..fb9c429a8 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Bugs fixed * #4727: Option clash for package textcomp * #4725: Sphinx does not work with python 3.5.0 and 3.5.1 * #4716: Generation PDF file with TexLive on Windows, file not found error +* #4574: vertical space before equation in latex Testing -------- From e3470bbde33bff93c363d86f7a2ad0380faecd07 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Fri, 16 Mar 2018 16:19:39 +0900 Subject: [PATCH 12/12] fix #4734: Describe how to specify make.bat parameter on Windows --- doc/intl.rst | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/doc/intl.rst b/doc/intl.rst index dacced65b..870d06240 100644 --- a/doc/intl.rst +++ b/doc/intl.rst @@ -113,12 +113,27 @@ This section describe an easy way to translate with sphinx-intl. #. make translated document. You need a :confval:`language` parameter in ``conf.py`` or you may also - specify the parameter on the command line: + specify the parameter on the command line (for BSD/GNU make): .. code-block:: console $ make -e SPHINXOPTS="-D language='de'" html + command line (for Windows cmd.exe): + + .. code-block:: console + + > set SPHINXOPTS=-D language='de' + > .\make.bat html + + command line (for PowerShell): + + .. code-block:: console + + > Set-Item env:SPHINXOPTS "-D language='de'" + > .\make.bat html + + Congratulations! You got the translated documentation in the ``_build/html`` directory. @@ -263,7 +278,7 @@ easy to fetch and push translations. ... Done. - Invoke make html: + Invoke make html (for BSD/GNU make): .. code-block:: console