瀏覽代碼

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 7 年之前
父節點
當前提交
f132d3b03b
共有 1 個文件被更改,包括 2 次插入0 次删除
  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