HomeSoftware Heritage

model: Make all classes slotted.

Description

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.

Details

Provenance
vlorentzAuthored on Dec 14 2020, 5:38 PM
vlorentzPushed on Dec 18 2020, 1:52 PM
Differential Revision
D4736: model: Make all classes slotted.
Parents
rDMODa3b6a6448011: Drop backwards-compatibility support for RawExtrinsicMetadata.id
Branches
Unknown
Tags
Unknown
Build Status
Buildable 18025
Build 27845: test-and-buildJenkins console · Jenkins