From eb07a0fee19a0a3e205755c7923e40a56a7a28db Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 1 Jul 2019 00:32:20 +0900 Subject: [PATCH] Migrate to py3 style type annotation: sphinx.ext.linkcode --- sphinx/ext/linkcode.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sphinx/ext/linkcode.py b/sphinx/ext/linkcode.py index 3ebdf7bc9..e8635d926 100644 --- a/sphinx/ext/linkcode.py +++ b/sphinx/ext/linkcode.py @@ -8,25 +8,23 @@ :license: BSD, see LICENSE for details. """ +from typing import Any, Dict, Set + from docutils import nodes +from docutils.nodes import Node import sphinx from sphinx import addnodes +from sphinx.application import Sphinx from sphinx.errors import SphinxError from sphinx.locale import _ -if False: - # For type annotation - from typing import Any, Dict, Set # NOQA - from sphinx.application import Sphinx # NOQA - class LinkcodeError(SphinxError): category = "linkcode error" -def doctree_read(app, doctree): - # type: (Sphinx, nodes.Node) -> None +def doctree_read(app: Sphinx, doctree: Node) -> None: env = app.builder.env resolve_target = getattr(env.config, 'linkcode_resolve', None) @@ -75,8 +73,7 @@ def doctree_read(app, doctree): signode += onlynode -def setup(app): - # type: (Sphinx) -> Dict[str, Any] +def setup(app: Sphinx) -> Dict[str, Any]: app.connect('doctree-read', doctree_read) app.add_config_value('linkcode_resolve', None, '') return {'version': sphinx.__display_version__, 'parallel_read_safe': True}