Skip to content
Snippets Groups Projects
Commit 76b744e0 authored by vlorentz's avatar vlorentz
Browse files

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.
parent a3b6a644
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment