From 68e248fa732c83d75f702bde9934032db9c974f5 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 16 Feb 2020 20:27:51 +0900 Subject: [PATCH] Fix #7161: autodoc: typehints extension does not support parallel build --- CHANGES | 1 + sphinx/ext/autodoc/typehints.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index bf0a55f759f..93b025647f7 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Bugs fixed * #7138: autodoc: ``autodoc.typehints`` crashed when variable has unbound object as a value * #7156: autodoc: separator for keyword only arguments is not shown +* #7161: autodoc: typehints extension does not support parallel build Testing -------- diff --git a/sphinx/ext/autodoc/typehints.py b/sphinx/ext/autodoc/typehints.py index 77934dae57f..64782dc1cde 100644 --- a/sphinx/ext/autodoc/typehints.py +++ b/sphinx/ext/autodoc/typehints.py @@ -18,19 +18,19 @@ from sphinx import addnodes from sphinx.application import Sphinx -from sphinx.config import ENUM +from sphinx.config import Config, ENUM from sphinx.util import inspect, typing -def config_inited(app, config): +def config_inited(app: Sphinx, config: Config) -> None: if config.autodoc_typehints == 'description': # HACK: override this to make autodoc suppressing typehints in signatures - config.autodoc_typehints = 'none' + config.autodoc_typehints = 'none' # type: ignore # preserve user settings - app._autodoc_typehints_description = True + app._autodoc_typehints_description = True # type: ignore else: - app._autodoc_typehints_description = False + app._autodoc_typehints_description = False # type: ignore def record_typehints(app: Sphinx, objtype: str, name: str, obj: Any, @@ -140,10 +140,16 @@ def modify_field_list(node: nodes.field_list, annotations: Dict[str, str]) -> No node += field -def setup(app): +def setup(app: Sphinx) -> Dict[str, Any]: app.setup_extension('sphinx.ext.autodoc') app.config.values['autodoc_typehints'] = ('signature', True, ENUM("signature", "description", "none")) app.connect('config-inited', config_inited) app.connect('autodoc-process-signature', record_typehints) app.connect('object-description-transform', merge_typehints) + + return { + 'version': 'builtin', + 'parallel_read_safe': True, + 'parallel_write_safe': True, + }