Skip to content

Commit

Permalink
Merge pull request #7162 from tk0miya/7161_autodoc.typhints_parallel_…
Browse files Browse the repository at this point in the history
…build

Fix #7161: autodoc: typehints extension does not support parallel build
  • Loading branch information
tk0miya authored Feb 16, 2020
2 parents 9f23744 + 39a192b commit 46f7dc5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Bugs fixed
as a value
* #7156: autodoc: separator for keyword only arguments is not shown
* #7146: autodoc: IndexError is raised on suppressed type_comment found
* #7161: autodoc: typehints extension does not support parallel build
* #7151: crashed when extension assigns a value to ``env.indexentries``

Testing
Expand Down
18 changes: 12 additions & 6 deletions sphinx/ext/autodoc/typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}

0 comments on commit 46f7dc5

Please sign in to comment.