This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Update the Sphinx directive for super from function to class
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, maggyero, rhettinger
Priority: normal Keywords: patch

Created on 2021-04-20 17:48 by maggyero, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25489 merged maggyero, 2021-04-20 17:49
Messages (8)
msg391458 - (view) Author: Géry (maggyero) * Date: 2021-04-20 17:48
This PR updates the page [*Built-in Functions*](https://docs.python.org/3.9/library/functions.html#super) of the Python library documentation: `super` is not a `function` (`isinstance(super, type(lambda: None))` is `False`), it is a `type` (`isinstance(super, type)` is `True`), like `int`, `tuple`, `set`, etc. So it should get the same “class” prefix, i.e.

> **super**([*type*[, *object-or-type*]])

should become

> *class* **super**([*type*[, *object-or-type*]])
msg391459 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-04-20 17:52
In general, we've decided not to do this.  We use function mark-up in the section on builtin functions even though many of these are actually types.

We use class markup in other sections because that markup is well suited to listing all the associated methods and attributes.
msg391463 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-04-20 18:31
Looking again, it seems to someone has already started applying class markup despite previous decisions not to do so.
msg391465 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-04-20 18:39
-0 on doing this.  While class markup has crept into the Built-in Functions section, super() isn't really used this way (people don't subclass it or run isinstance on it).

Elsewhere in the docs, all the links to this entry use the markup, :func:`super` which looks nicer in the docs than the class reference.

In terms of markup, "function" is a role rather than an actual type, it is used for most callables whether or not ``isinstance(obj, type(lambda: None))`` returns true.
msg391466 - (view) Author: Géry (maggyero) * Date: 2021-04-20 18:39
> Looking again, it seems to someone has already started applying class markup despite previous decisions not to do so.

Yes, and he forgot super:

class bool([x])
class bytearray([source[, encoding[, errors]]])
class bytes([source[, encoding[, errors]]])
class complex([real[, imag]])
class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)
class float([x])
class frozenset([iterable])
class int([x])
class int(x, base=10)
class list([iterable])
class memoryview(obj)
class object
class property(fget=None, fset=None, fdel=None, doc=None)
class range(stop)
class range(start, stop[, step])
class set([iterable])
class slice(stop)
class slice(start, stop[, step])
class str(object='')
class str(object=b'', encoding='utf-8', errors='strict’)
class tuple([iterable])
class type(object)
class type(name, bases, dict, **kwds)
msg391467 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-04-20 18:41
Also, the related text uses callable terminology, "it returns object that ...".
msg391468 - (view) Author: Géry (maggyero) * Date: 2021-04-20 18:51
> Elsewhere in the docs, all the links to this entry use the markup, :func:`super` which looks nicer in the docs than the class reference.

I was suggesting only to update the block Sphinx directive “.. function::” to “.. class::” for defining the signature (so that the “class” prefix appears before the signature, like for the other built-in types), not the inline Sphinx roles “:func:” to “:class:” (since for instance `int` use both in the page: :class:`int` and :func:`int`).

Also the “class” prefix already appears in the interactive help when typing `help(super)`:

Help on class super in module builtins:

class super(object)
 |  super() -> same as super(__class__, <first argument>)
 |  super(type) -> unbound super object
 |  super(type, obj) -> bound super object; requires isinstance(obj, type)
 |  super(type, type2) -> bound super object; requires issubclass(type2, type)
 |  Typical use to call a cooperative superclass method:
 |  class C(B):
 |      def meth(self, arg):
 |          super().meth(arg)
 |  This works for class methods too:
 |  class C(B):
 |      @classmethod
 |      def cmeth(cls, arg):
 |          super().cmeth(arg)
msg391477 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-04-20 21:05
I've applied this PR but still am not sure that it makes readers better-off.
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 88062
2021-04-20 21:05:23rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg391477
2021-04-20 18:51:17maggyerosetmessages: + msg391468
2021-04-20 18:41:38rhettingersetmessages: + msg391467
2021-04-20 18:39:49maggyerosetmessages: + msg391466
2021-04-20 18:39:23rhettingersetmessages: + msg391465
2021-04-20 18:31:36rhettingersetstatus: closed -> open
resolution: rejected -> (no value)
messages: + msg391463

versions: - Python 3.6, Python 3.7, Python 3.8
2021-04-20 17:52:56rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg391459

resolution: rejected
stage: patch review -> resolved
2021-04-20 17:49:16maggyerosetkeywords: + patch
stage: patch review
pull_requests: + pull_request24212
2021-04-20 17:48:52maggyerocreate