Skip to content

Commit

Permalink
autodoc: Fix UnboundLocalError in filter_members (#11651)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Aug 28, 2023
1 parent 5e88b9f commit 1567281
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -678,9 +678,23 @@ def is_filtered_inherited_member(name: str, obj: Any) -> bool:
try:
membername = obj.__name__
member = obj.object
# if isattr is True, the member is documented as an attribute
isattr = member is INSTANCEATTR or (namespace, membername) in attr_docs
except AttributeError:
if isinstance(obj, ObjectMember):
raise
# To be removed, retained for compatibility.
# See https://github.com/sphinx-doc/sphinx/issues/11631
membername, member = obj
warnings.warn(
'Returning tuples of (name, object) as '
'the second return value from get_object_members() is deprecated. '
'Return ObjectMember(name, object) instances instead.',
RemovedInSphinx80Warning, stacklevel=2,
)

# if isattr is True, the member is documented as an attribute
isattr = member is INSTANCEATTR or (namespace, membername) in attr_docs

try:
doc = getdoc(member, self.get_attr, self.config.autodoc_inherit_docstrings,
self.object, membername)
if not isinstance(doc, str):
Expand Down

0 comments on commit 1567281

Please sign in to comment.