diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 86bcf88e5..9601d8e43 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -24,6 +24,7 @@ from .deprecation import RemovedInSphinx20Warning if False: # For type annotation + # note: Don't use typing.TYPE_CHECK here (for py27 and py34). from typing import Any # NOQA diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py index f397631fb..f6616e497 100644 --- a/sphinx/apidoc.py +++ b/sphinx/apidoc.py @@ -10,13 +10,12 @@ """ import warnings +from typing import TYPE_CHECKING from sphinx.deprecation import RemovedInSphinx20Warning from sphinx.ext.apidoc import main as _main - -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/ext/autosectionlabel.py b/sphinx/ext/autosectionlabel.py index 7a10b3e8d..80ca92711 100644 --- a/sphinx/ext/autosectionlabel.py +++ b/sphinx/ext/autosectionlabel.py @@ -16,8 +16,7 @@ from docutils import nodes from sphinx.util import logging from sphinx.util.nodes import clean_astext -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/ext/extlinks.py b/sphinx/ext/extlinks.py index 29bfe928f..53b051c45 100644 --- a/sphinx/ext/extlinks.py +++ b/sphinx/ext/extlinks.py @@ -24,14 +24,15 @@ :license: BSD, see LICENSE for details. """ +from typing import TYPE_CHECKING + from docutils import nodes, utils from six import iteritems import sphinx from sphinx.util.nodes import split_explicit_title -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any, Dict, List, Tuple # NOQA from docutils.parsers.rst.states import Inliner # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/ext/githubpages.py b/sphinx/ext/githubpages.py index bd7061fb7..f97c810f8 100644 --- a/sphinx/ext/githubpages.py +++ b/sphinx/ext/githubpages.py @@ -10,11 +10,11 @@ """ import os +from typing import TYPE_CHECKING import sphinx -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA from sphinx.environment import BuildEnvironment # NOQA diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py index b718162d2..e523b54c8 100644 --- a/sphinx/ext/jsmath.py +++ b/sphinx/ext/jsmath.py @@ -10,6 +10,8 @@ :license: BSD, see LICENSE for details. """ +from typing import TYPE_CHECKING + from docutils import nodes import sphinx @@ -19,8 +21,7 @@ from sphinx.ext.mathbase import setup_math as mathbase_setup from sphinx.locale import _ -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py index 4ebfd35ed..9f8013b2b 100644 --- a/sphinx/ext/mathjax.py +++ b/sphinx/ext/mathjax.py @@ -11,6 +11,8 @@ :license: BSD, see LICENSE for details. """ +from typing import TYPE_CHECKING + from docutils import nodes import sphinx @@ -19,9 +21,7 @@ from sphinx.ext.mathbase import get_node_equation_number from sphinx.ext.mathbase import setup_math as mathbase_setup from sphinx.locale import _ - -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 8cad0640b..dbdfb47c1 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -10,12 +10,12 @@ """ import warnings +from typing import TYPE_CHECKING from sphinx.cmd.quickstart import main as _main from sphinx.deprecation import RemovedInSphinx20Warning -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/da.py b/sphinx/search/da.py index aac6c4130..186219cca 100644 --- a/sphinx/search/da.py +++ b/sphinx/search/da.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/de.py b/sphinx/search/de.py index 87c4cf617..186e4ab08 100644 --- a/sphinx/search/de.py +++ b/sphinx/search/de.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/es.py b/sphinx/search/es.py index 972ec1495..48783feff 100644 --- a/sphinx/search/es.py +++ b/sphinx/search/es.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/fi.py b/sphinx/search/fi.py index b089bef3a..039035bd6 100644 --- a/sphinx/search/fi.py +++ b/sphinx/search/fi.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/fr.py b/sphinx/search/fr.py index 0f2b68a69..0c42843ec 100644 --- a/sphinx/search/fr.py +++ b/sphinx/search/fr.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/hu.py b/sphinx/search/hu.py index d3bcf2974..c2abbd677 100644 --- a/sphinx/search/hu.py +++ b/sphinx/search/hu.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/it.py b/sphinx/search/it.py index 64d7c7538..1a26c4488 100644 --- a/sphinx/search/it.py +++ b/sphinx/search/it.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/nl.py b/sphinx/search/nl.py index 32fb86937..fc26bbd2f 100644 --- a/sphinx/search/nl.py +++ b/sphinx/search/nl.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/no.py b/sphinx/search/no.py index d1f849228..d582cd02c 100644 --- a/sphinx/search/no.py +++ b/sphinx/search/no.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/pt.py b/sphinx/search/pt.py index dc43c0330..1fd0b65c8 100644 --- a/sphinx/search/pt.py +++ b/sphinx/search/pt.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/ru.py b/sphinx/search/ru.py index 75870b08f..085569f20 100644 --- a/sphinx/search/ru.py +++ b/sphinx/search/ru.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any # NOQA diff --git a/sphinx/search/sv.py b/sphinx/search/sv.py index 555b4b641..f6d40feed 100644 --- a/sphinx/search/sv.py +++ b/sphinx/search/sv.py @@ -15,8 +15,7 @@ from sphinx.search import SearchLanguage, parse_stop_word import snowballstemmer -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any swedish_stopwords = parse_stop_word(u''' diff --git a/sphinx/testing/path.py b/sphinx/testing/path.py index 209046246..5f59ad30b 100644 --- a/sphinx/testing/path.py +++ b/sphinx/testing/path.py @@ -10,11 +10,11 @@ import os import shutil import sys from io import open +from typing import TYPE_CHECKING from six import PY2, text_type -if False: - # For type annotation +if TYPE_CHECKING: from typing import Any, Callable, IO, List # NOQA