Skip to content

model: Make all classes slotted.

Unfortunately, sphinx (actually, autodoc) only picks up attributes if they fall in any of these cases:

  1. are enum variants
  2. are in slots
  3. are in dict
  4. have an annotation
  5. are found using its custom parser

(see get_object_members in sphinx/ext/autodoc/importer.py)

In theory, option 5 should work for us; unfortunately, autodoc only asks the parser the list of members with a comment. And it's not easy to adapt it to ask the parser for all members, because said parser (sphinx/pycode/parser.py) does not return the class qualname (aka. namespace) for members without comments.

So, as I don't want to change the interface of sphinx.pycode.parser, this commit switches to relying on option 3, by adding slots for all attr classes.

Additionally, this might have some performance/memory improvement (though I did not check) and will further avoid mutation of these objects.


Migrated from D4736 (view on Phabricator)

Merge request reports