Skip to content
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

Silence a noisy warning when building docs #169

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion autoautosummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from docutils import nodes
from docutils.parsers.rst import directives
from sphinx.ext import autosummary
from sphinx.ext.autosummary import Autosummary, get_documenter
from sphinx.ext.autosummary import Autosummary, ImportExceptionGroup, get_documenter
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.inspect import isstaticmethod, safe_getattr
Expand Down Expand Up @@ -140,6 +140,28 @@ def get_members(
print(str(e))
raise e

def import_by_name(
self,
name: str,
prefixes: list[str | None],
) -> tuple[str, Any, Any, str]:
"""
We have to wrap the original import_by_name, which raises noisy
exceptions when trying to handle class attributes exposed by SIP.
"""
try:
res = super().import_by_name(name, prefixes)
except ImportExceptionGroup:
# class attribute import failed, just handle this by faking
# the results. The resultant documentation still correctly
# contains the attribute docstrings...
name_parts = name.split(".")
parent_name = ".".join(name_parts[:-1])
parent_res = super().import_by_name(parent_name, prefixes)
res = (name, None, parent_res[2], parent_res[3])

return res

def run(self):
clazz = self.arguments[0]
rubric_title = None
Expand Down