From 4ad88525eca951ccf718931fc845bebf181dd419 Mon Sep 17 00:00:00 2001 From: Joseph Martinot-Lagarde Date: Sat, 3 Jun 2023 20:21:26 +0200 Subject: [PATCH 1/2] Always use __dict__ and ignore __slots__ on classes --- sphinx_automodapi/automodsumm.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/sphinx_automodapi/automodsumm.py b/sphinx_automodapi/automodsumm.py index 10a71f6..5192c83 100644 --- a/sphinx_automodapi/automodsumm.py +++ b/sphinx_automodapi/automodsumm.py @@ -528,25 +528,11 @@ def get_members_class(obj, typ, include_public=[], items = [] # using dir gets all of the attributes, including the elements - # from the base class, otherwise use __slots__ or __dict__ + # from the base class, otherwise use __dict__ if include_base: names = dir(obj) else: - # Classes deriving from an ABC using the `abc` module will - # have an empty `__slots__` attribute in Python 3, unless - # other slots were declared along the inheritance chain. If - # the ABC-derived class has empty slots, we'll use the - # class `__dict__` instead. - declares_slots = ( - hasattr(obj, '__slots__') and - not (issubclass(type(obj), abc.ABCMeta) and - len(obj.__slots__) == 0) - ) - - if declares_slots: - names = tuple(getattr(obj, '__slots__')) - else: - names = getattr(obj, '__dict__').keys() + names = getattr(obj, '__dict__').keys() for name in names: try: From 6bbddc0287bf1d0044e79b2d08ca6f1d31996da6 Mon Sep 17 00:00:00 2001 From: Joseph Martinot-Lagarde Date: Sat, 3 Jun 2023 21:22:38 +0200 Subject: [PATCH 2/2] abc module unused --- sphinx_automodapi/automodsumm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sphinx_automodapi/automodsumm.py b/sphinx_automodapi/automodsumm.py index 5192c83..e3579da 100644 --- a/sphinx_automodapi/automodsumm.py +++ b/sphinx_automodapi/automodsumm.py @@ -83,7 +83,6 @@ class members that are inherited from a base class. This value can be .. _sphinx.ext.inheritance_diagram: http://sphinx-doc.org/latest/ext/inheritance.html """ -import abc import inspect import os import re