diff options
Diffstat (limited to 'sphinx/util/inspect.py')
-rw-r--r-- | sphinx/util/inspect.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 492db8700..5dab5a710 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -244,8 +244,19 @@ def object_description(object): except TypeError: pass # Cannot sort dict keys, fall back to generic repr else: - items = ("%r: %r" % (key, object[key]) for key in sorted_keys) + items = ("%s: %s" % + (object_description(key), object_description(object[key])) + for key in sorted_keys) return "{%s}" % ", ".join(items) + if isinstance(object, set): + try: + sorted_values = sorted(object) + except TypeError: + pass # Cannot sort set values, fall back to generic repr + else: + template = "{%s}" if PY3 else "set([%s])" + return template % ", ".join(object_description(x) + for x in sorted_values) try: s = repr(object) except Exception: @@ -583,6 +594,7 @@ else: # of Python 3.5 def _findclass(func): + # type: (Any) -> Any cls = sys.modules.get(func.__module__) if cls is None: return None @@ -596,6 +608,7 @@ else: return cls def _finddoc(obj): + # type: (Any) -> unicode if inspect.isclass(obj): for base in obj.__mro__: if base is not object: @@ -656,6 +669,7 @@ else: return None def getdoc(object): + # type: (Any) -> unicode """Get the documentation string for an object. All tabs are expanded to spaces. To clean up docstrings that are |