Skip to content

autosummary templates have too little context for class members: attributes vs properties, abstract methods, etc… #14264

Open

Description

@flying-sheep

Is your feature request related to a problem? Please describe.
In an ideal world, I’d document properties using .. autoproperty:: and attributes using .. autoattribute::, as this way, their types are displayed correctly.

I can document properties using .. autoattribute::, but I can’t document attributes using .. autoproperty:: as that would crash with

AttributeError: type object 'Bar' has no attribute 'foo'

And since autosummary’s lists of strings that it passes to templates doesn’t have information about member objtypes, I can’t distinguish between the two.

Describe the solution you'd like
Replace the multitude of member lists passed to the class template with a single list of objects that contain all relevant information:

  • name: str
  • type: Literal['attribute', 'property', 'method', …]
  • is_abstract: bool (is True for methods and properties marked with @abc.abstractmethod)
  • is_staticmethod: bool and is_classmethod: bool (can be True for methods)
  • is_inherited: bool
  • …

This could then be use like this:

{% block attributes %}
{% set attrs = attributes | selectattr("objtype", "in", {"attribute", "property"}) | list %}
{% if attrs  %}
.. rubric:: Attributes

{% for item in attrs %}
{% if item.obtype == "property" %}
.. autoproperty:: {{ item }}
{% else %}
.. autoattribute:: {{ item }}
{% endif %}
{%- endfor %}
{% endif %}
{% endblock %}

Describe alternatives you've considered
Add more lists to the template like property_members, abstract_members, …, so we can use that in {% if item in property_members %}

Activity

  1. added
    type:proposal
    on Jan 16, 2026
  2. changed the title [-]allow distinguishing attributes and properties in autosummary templates[/-] [+]autosummary templates have too little context for class members: attributes vs properties, abstract methods, etc…[/+] on Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:proposal

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions