From ed987513111ab918c5a7b31ef84177062f261e8c Mon Sep 17 00:00:00 2001 From: Kyle D Fawcett Date: Tue, 19 Dec 2023 11:18:49 -0500 Subject: [PATCH] FIX: fixes __slots__ hides class variables #168 --- CHANGES.rst | 1 + sphinx_automodapi/automodsumm.py | 19 ++----------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f8bb685..f2be1e8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changes in sphinx-automodapi 0.17.0 (unreleased) ------------------- +- Fixes fixes ``__slots__`` hides class variables [#168] - Minimum supported Python version is now 3.8. [#177] 0.16.0 (2023-08-17) diff --git a/sphinx_automodapi/automodsumm.py b/sphinx_automodapi/automodsumm.py index ec99ce8..ecdd3fe 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 @@ -555,25 +554,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: