File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,11 @@ Features added
65
65
and rename the :rst:dir: `autosummary ` directive's ``nosignatures``option
66
66
to :rst:dir:`no-signatures ``.
67
67
Patch by Adam Turner.
68
+ * #13269: Added the option to disable the use of type comments in
69
+ via the new :confval: `autodoc_use_type_comments ` option,
70
+ which defaults to ``True `` for backwards compatibility.
71
+ The default will change to ``False `` in Sphinx 10.
72
+ Patch by Adam Turner.
68
73
69
74
Bugs fixed
70
75
----------
Original file line number Diff line number Diff line change @@ -1230,6 +1230,26 @@ There are also config values that you can set:
1230
1230
Added as an experimental feature. This will be integrated into autodoc core
1231
1231
in the future.
1232
1232
1233
+ .. confval :: autodoc_use_type_comments
1234
+ :type: :code-py: `bool `
1235
+ :default: :code-py: `True `
1236
+
1237
+ Attempt to read ``# type: ... `` comments from source code
1238
+ to supplement missing type annotations, if True.
1239
+
1240
+ This can be disabled if your source code does not use type comments,
1241
+ for example if it exclusively uses type annotations or
1242
+ does not use type hints of any kind.
1243
+
1244
+ .. versionadded :: 8.2
1245
+
1246
+ Added the option to disable the use of type comments in
1247
+ via the new :confval: `!autodoc_use_type_comments ` option,
1248
+ which defaults to :code-py: `True ` for backwards compatibility.
1249
+ The default will change to :code-py: `False ` in Sphinx 10.
1250
+
1251
+ .. xref RemovedInSphinx10Warning
1252
+
1233
1253
.. confval :: autodoc_warningiserror
1234
1254
:type: :code-py: `bool `
1235
1255
:default: :code-py: `True `
Original file line number Diff line number Diff line change @@ -131,6 +131,9 @@ def update_annotations_using_type_comments(
131
131
app : Sphinx , obj : Any , bound_method : bool
132
132
) -> None :
133
133
"""Update annotations info of *obj* using type_comments."""
134
+ if not app .config .autodoc_use_type_comments :
135
+ return
136
+
134
137
try :
135
138
type_sig = get_type_comment (obj , bound_method )
136
139
if type_sig :
@@ -152,6 +155,9 @@ def update_annotations_using_type_comments(
152
155
153
156
154
157
def setup (app : Sphinx ) -> ExtensionMetadata :
158
+ app .add_config_value (
159
+ 'autodoc_use_type_comments' , True , 'env' , types = frozenset ({bool })
160
+ )
155
161
app .connect (
156
162
'autodoc-before-process-signature' , update_annotations_using_type_comments
157
163
)
You can’t perform that action at this time.
0 commit comments