[Python-modules-commits] [sphinx] 01/02: Fix autodoc failures with python3.5 3.5.2-7

Dmitry Shachnev mitya57 at moszumanska.debian.org
Wed Nov 16 20:11:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

mitya57 pushed a commit to branch master
in repository sphinx.

commit ddd4d17b2143738691df1b4aff0f187715a22d60
Author: Takeshi KOMIYA <i.tkomiya at gmail.com>
Date:   Wed Nov 2 20:06:30 2016 +0900

    Fix autodoc failures with python3.5 3.5.2-7
    
    See upstream issue:
    https://github.com/sphinx-doc/sphinx/issues/3111
    
    (cherry picked from upstream commit bcff35663f67d3e3)
    
    Patch-Name: fix_autodoc_new_python.diff
---
 sphinx/ext/autodoc.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index 967bead..208a228 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -263,6 +263,8 @@ def format_annotation(annotation):
     """
     if typing and isinstance(annotation, typing.TypeVar):
         return annotation.__name__
+    if annotation == Ellipsis:
+        return '...'
     if not isinstance(annotation, type):
         return repr(annotation)
 
@@ -281,7 +283,12 @@ def format_annotation(annotation):
             # arguments are in __parameters__.
             params = None
             if hasattr(annotation, '__args__'):
-                params = annotation.__args__
+                if len(annotation.__args__) <= 2:
+                    params = annotation.__args__
+                else:  # typing.Callable
+                    args = ', '.join(format_annotation(a) for a in annotation.__args__[:-1])
+                    result = format_annotation(annotation.__args__[-1])
+                    return '%s[[%s], %s]' % (qualified_name, args, result)
             elif hasattr(annotation, '__parameters__'):
                 params = annotation.__parameters__
             if params is not None:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/sphinx.git



More information about the Python-modules-commits mailing list