autodoc: Improve support for non-weakreferencable objects

This commit is contained in:
Adam Turner
2025-12-27 03:03:14 +00:00
parent 964424b3db
commit d59b237594
3 changed files with 7 additions and 3 deletions
+2
View File
@@ -42,6 +42,8 @@ Bugs fixed
Patch by Jean-François B.
* #14064: LaTeX: TABs ending up in sphinxVerbatim fail to obey tab stops.
Patch by Jean-François B.
* #14089: autodoc: Improve support for non-weakreferencable objects.
Patch by Adam Turner
Testing
-------
+3 -2
View File
@@ -360,7 +360,8 @@ def _make_props_from_imported_object(
if objtype == 'data':
# Update __annotations__ to support type_comment and so on
_ensure_annotations_from_type_comments(parent)
if config.autodoc_use_type_comments:
_ensure_annotations_from_type_comments(parent)
# obtain annotation
annotations = get_type_hints(
@@ -410,7 +411,7 @@ def _make_props_from_imported_object(
obj = SLOTS_ATTR
elif inspect.isenumattribute(obj):
obj = obj.value
if parent:
if parent and config.autodoc_use_type_comments:
# Update __annotations__ to support type_comment and so on
_ensure_annotations_from_type_comments(parent)
@@ -50,7 +50,8 @@ def _ensure_annotations_from_type_comments(obj: Any) -> None:
"""
if obj in _objects_with_type_comment_annotations:
return
_objects_with_type_comment_annotations.add(obj)
with contextlib.suppress(TypeError):
_objects_with_type_comment_annotations.add(obj)
if isinstance(obj, type):
for cls in inspect.getmro(obj):