diff --git a/sphinx/application.py b/sphinx/application.py index 1495d6eaf..d118c2afe 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -122,7 +122,7 @@ class Sphinx(object): self.enumerable_nodes = {} # type: Dict[nodes.Node, Tuple[unicode, Callable]] # NOQA self.html_themes = {} # type: Dict[unicode, unicode] - self.srcdir = srcdir + self.srcdir = srcdir # type: unicode self.confdir = confdir self.outdir = outdir self.doctreedir = doctreedir diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index c1bb4dbf2..6fef3e95f 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -594,9 +594,9 @@ class StandaloneHTMLBuilder(Builder): doctree.settings = self.docsettings self.secnumbers = self.env.toc_secnumbers.get(docname, {}) - self.fignumbers = self.env.toc_fignumbers.get(docname, {}) + self.fignumbers = self.env.toc_fignumbers.get(docname, {}) # type: Dict[unicode, Dict[unicode, Tuple[int, ...]]] # NOQA self.imgpath = relative_uri(self.get_target_uri(docname), '_images') - self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads') + self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads') # type: unicode self.current_docname = docname self.docwriter.write(doctree, destination) self.docwriter.assemble_parts() diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index b53fec888..94dd4187f 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -169,8 +169,8 @@ class BuildEnvironment(object): # type: (Sphinx) -> None self.app = app self.doctreedir = app.doctreedir - self.srcdir = app.srcdir - self.config = app.config + self.srcdir = app.srcdir # type: unicode + self.config = app.config # type: Config # the method of doctree versioning; see set_versioning_method self.versioning_condition = None # type: Union[bool, Callable] @@ -187,7 +187,7 @@ class BuildEnvironment(object): self._warnfunc = None # type: Callable # this is to invalidate old pickles - self.version = ENV_VERSION + self.version = ENV_VERSION # type: int # All "docnames" here are /-separated and relative and exclude # the source suffix. @@ -252,8 +252,8 @@ class BuildEnvironment(object): # lineno, module, descname, content) # these map absolute path -> (docnames, unique filename) - self.images = FilenameUniqDict() - self.dlfiles = FilenameUniqDict() + self.images = FilenameUniqDict() # type: FilenameUniqDict + self.dlfiles = FilenameUniqDict() # type: FilenameUniqDict # the original URI for images self.original_image_uri = {} # type: Dict[unicode, unicode] diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index a02286c28..8b9e90e57 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -41,6 +41,7 @@ if TYPE_CHECKING: from docutils import nodes # NOQA from docutils.utils import Reporter # NOQA from sphinx.application import Sphinx # NOQA + from sphinx.environment import BuildEnvironment # NOQA from sphinx.ext.autodoc.directive import DocumenterBridge # NOQA logger = logging.getLogger(__name__) @@ -281,7 +282,7 @@ class Documenter(object): def __init__(self, directive, name, indent=u''): # type: (DocumenterBridge, unicode, unicode) -> None self.directive = directive - self.env = directive.env + self.env = directive.env # type: BuildEnvironment self.options = directive.genopt self.name = name self.indent = indent @@ -745,7 +746,7 @@ class Documenter(object): # where the attribute documentation would actually be found in. # This is used for situations where you have a module that collects the # functions and classes of internal submodules. - self.real_modname = real_modname or self.get_real_modname() + self.real_modname = real_modname or self.get_real_modname() # type: str # try to also get a source code analyzer for attribute docs try: diff --git a/sphinx/io.py b/sphinx/io.py index 88fee462f..113322e4b 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) + pub.process_programmatic_settings(None, env.settings, None) # type: ignore pub.set_source(source, filename) pub.publish() return pub.document diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py index 73513598c..12dc18694 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'] + language = self.env.settings['language_code'] # type: ignore for tag in normalize_language_tag(language): if tag in smartchars.quotes: return True