Chilipp / autodocsumm

Extending your autodoc API docs with a summary
Apache License 2.0
48 stars 14 forks source link

Sphinx `ObjectMember`-related deprecations #89

Open AnonymouX47 opened 11 months ago

AnonymouX47 commented 11 months ago

After upgrading Sphinx from 6.1.2 to 7.2.6 (with autodocsumm 0.2.11), the following warnings are issued while building docs:

  1. At https://github.com/Chilipp/autodocsumm/blob/7009e5ec0de58ac2675269829ca602447113d6e2/autodocsumm/__init__.py#L223
    RemovedInSphinx80Warning: The tuple interface of ObjectMember is deprecated. Use (obj.__name__, obj.object) instead.
     members = [(membername, member) for (membername, member) in members
  2. At https://github.com/Chilipp/autodocsumm/blob/7009e5ec0de58ac2675269829ca602447113d6e2/autodocsumm/__init__.py#L230
    RemovedInSphinx80Warning: Returning tuples of (name, object) as the second return value from get_object_members() is deprecated. Return ObjectMember(name, object) instances instead.
     for (mname, member, isattr) in self.filter_members(members, want_all):

From the name of the warning class, it seems the deprecated features will be removed in Sphinx 8.0.

I checked through the changelog but couldn't find any reference to these deprecations. Anyways, I looked a little further and found the following:

From these, the deprecations seem to have started from Sphinx 7.2.0.


I tried

@@ -220,8 +220,8 @@ class AutosummaryDocumenter(object):

         # remove members given by exclude-members
         if self.options.exclude_members:
-            members = [(membername, member) for (membername, member) in members
-                       if membername not in self.options.exclude_members]
+            members = [member for member in members
+                       if member.__name__ not in self.options.exclude_members]

         # document non-skipped members
         memberdocumenters = []

but results in

AttributeError: 'tuple' object has no attribute '__name__'

which is honestly quite confusing since the contents of members seem to be ObjectMember instances from the deprecation warning message above.

Anyways, I'm not sure I know how to go about fixing them since I'm not quite familiar with Sphinx extension code but obviously, a proper fix will have to do with https://github.com/Chilipp/autodocsumm/blob/7009e5ec0de58ac2675269829ca602447113d6e2/autodocsumm/__init__.py#L219 and https://github.com/Chilipp/autodocsumm/blob/7009e5ec0de58ac2675269829ca602447113d6e2/autodocsumm/__init__.py#L223-L224


Also, I noticed a couple other unrelated deprecation warnings while running the tests (with Sphinx 7.2.6).

Chilipp commented 1 month ago

@AnonymouX47, my apologies for coming back to you so late. Is this still an issue with autodocsumm v0.2.13 or can we close this issue?

domdfcoding commented 4 weeks ago

Yes still an issue (and on Sphinx 8.0 is now an error)

theOehrly commented 4 weeks ago

@domdfcoding @AnonymouX47 can you provide an example that produces this error? I wanted to take a look at it but the project where I tried it did not produce that warning (or the error now).