Browse Source

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 năm trước cách đây
mục cha
commit
f132d3b03b
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  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