WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a0291ee

Browse files
committed
docs(conf) Suppress forward reference warnings from sphinx-autodoc-typehints
why: Types in TYPE_CHECKING blocks (used for circular import avoidance) cause sphinx-autodoc-typehints to emit warnings about unresolvable forward references. These warnings are expected and safe to suppress. what: - Add suppress_warnings config for sphinx_autodoc_typehints.forward_reference
1 parent 2472a95 commit a0291ee

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

docs/conf.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@
110110
# sphinx.ext.autodoc
111111
autoclass_content = "both"
112112
autodoc_member_order = "bysource"
113+
# Don't show class signature with the class' name.
114+
autodoc_class_signature = "separated"
113115
toc_object_entries_show_parents = "hide"
114116
autodoc_default_options = {
115117
"undoc-members": True,
@@ -120,7 +122,9 @@
120122
}
121123

122124
# sphinx-autodoc-typehints
123-
autodoc_typehints = "description" # show type hints in doc body instead of signature
125+
# Automatically extract typehints when specified and place them in
126+
# descriptions of the relevant function/method.
127+
autodoc_typehints = "description"
124128
simplify_optional_unions = True
125129

126130
# sphinx.ext.napoleon
@@ -153,7 +157,15 @@
153157

154158
# Keep network lookups fast and quiet when inventories are slow or unreachable.
155159
intersphinx_timeout = 1
156-
suppress_warnings = ["intersphinx", "intersphinx.inventory"]
160+
161+
# sphinx-autodoc-typehints
162+
# Suppress warnings for forward references that can't be resolved
163+
# (types in TYPE_CHECKING blocks used for circular import avoidance)
164+
suppress_warnings = [
165+
"intersphinx",
166+
"intersphinx.inventory",
167+
"sphinx_autodoc_typehints.forward_reference",
168+
]
157169

158170

159171
def linkcode_resolve(domain: str, info: dict[str, str]) -> None | str:

0 commit comments

Comments
 (0)