mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
typehints: Fix wrong order of info-field-list
This commit is contained in:
parent
0f8a868bf7
commit
377c29db78
@ -9,6 +9,7 @@
|
||||
"""
|
||||
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, Iterable
|
||||
from typing import cast
|
||||
|
||||
@ -37,13 +38,14 @@ def record_typehints(app: Sphinx, objtype: str, name: str, obj: Any,
|
||||
"""Record type hints to env object."""
|
||||
try:
|
||||
if callable(obj):
|
||||
annotations = app.env.temp_data.setdefault('annotations', {}).setdefault(name, {})
|
||||
annotations = app.env.temp_data.setdefault('annotations', {})
|
||||
annotation = annotations.setdefault(name, OrderedDict())
|
||||
sig = inspect.signature(obj)
|
||||
for param in sig.parameters.values():
|
||||
if param.annotation is not param.empty:
|
||||
annotations[param.name] = typing.stringify(param.annotation)
|
||||
annotation[param.name] = typing.stringify(param.annotation)
|
||||
if sig.return_annotation is not sig.empty:
|
||||
annotations['return'] = typing.stringify(sig.return_annotation)
|
||||
annotation['return'] = typing.stringify(sig.return_annotation)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user