-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using __slots__ hides class variables #168
Comments
After mode digging, I found that my suggestion was wrong. Actually I think that Here is an example: from pprint import pprint
class A:
__slots__ = ("a", "b")
def __init__(self):
self.a = 0
def func(self):
"""Documentation"""
return 1
pprint(tuple(getattr(A, "__slots__"))) # ('a', 'b')
pprint(getattr(A, "__dict__").keys()) # dict_keys(['__module__', '__slots__', '__init__', 'func', 'a', 'b', '__doc__']) Notice that the last line yields correctly |
kylefawcett
pushed a commit
to kylefawcett/sphinx-automodapi
that referenced
this issue
Dec 19, 2023
kylefawcett
pushed a commit
to kylefawcett/sphinx-automodapi
that referenced
this issue
Dec 19, 2023
kylefawcett
pushed a commit
to kylefawcett/sphinx-automodapi
that referenced
this issue
Dec 19, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If
__slots__
is declared in a class, it takes precedence over everything, including class methods and variables. However__slots__
has an effect on instance attributes only, not class attributes.The relevant lines is https://github.com/astropy/sphinx-automodapi/blob/0aad86aa90bcd7ab5b3004b732e21a3bd3d9de70/sphinx_automodapi/automodsumm.py#LL534C33-L549C33. Maybe
names
should also be filled withgetattr(type(obj), '__dict__').keys()
or something like that ?The text was updated successfully, but these errors were encountered: