Browse Source

Fix getfullargspec Python 2.x compatibility in contrib/sphinx.py (#4399)

* In Python 2.x, when documenting tasks with autotask an error was
  being thrown since the named tuple passed to formatargspec was
  was meant for Python 3 (fixes #3993)
Javier Martin Montull 7 years ago
parent
commit
d7d4c2a40e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      celery/contrib/sphinx.py

+ 4 - 2
celery/contrib/sphinx.py

@@ -29,11 +29,13 @@ using `:task:proj.tasks.add` syntax.
 Use ``.. autotask::`` to manually document a task.
 """
 from __future__ import absolute_import, unicode_literals
-from inspect import formatargspec
 from sphinx.domains.python import PyModulelevel
 from sphinx.ext.autodoc import FunctionDocumenter
 from celery.app.task import BaseTask
-from celery.five import getfullargspec
+try:  # pragma: no cover
+    from inspect import formatargspec, getfullargspec
+except ImportError:  # Py2
+    from inspect import formatargspec, getargspec as getfullargspec  # noqa
 
 
 class TaskDocumenter(FunctionDocumenter):