Explorar el Código

Strip `self` from sphinx documentation of bound tasks (#4421)

In Sphinx-generated documentation, the `self` argument should be
hidden from the signature of a task that was created with
`bind=True`.

(Sphinx does normally strip the `self` or `cls` argument from
method signatures.)
Leo Singer hace 7 años
padre
commit
f132d3b03b
Se han modificado 1 ficheros con 2 adiciones y 0 borrados
  1. 2 0
      celery/contrib/sphinx.py

+ 2 - 0
celery/contrib/sphinx.py

@@ -54,6 +54,8 @@ class TaskDocumenter(FunctionDocumenter):
         wrapped = getattr(self.object, '__wrapped__', None)
         if wrapped is not None:
             argspec = getfullargspec(wrapped)
+            if argspec[0] and argspec[0][0] in ('cls', 'self'):
+                del argspec[0][0]
             fmt = formatargspec(*argspec)
             fmt = fmt.replace('\\', '\\\\')
             return fmt