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
6565 and rename the :rst:dir: `autosummary ` directive's ``nosignatures``option
6666 to :rst:dir:`no-signatures ``.
6767 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.
6873
6974Bugs fixed
7075----------
Original file line number Diff line number Diff line change @@ -1230,6 +1230,26 @@ There are also config values that you can set:
12301230 Added as an experimental feature. This will be integrated into autodoc core
12311231 in the future.
12321232
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+
12331253 .. confval :: autodoc_warningiserror
12341254 :type: :code-py: `bool `
12351255 :default: :code-py: `True `
Original file line number Diff line number Diff line change @@ -131,6 +131,9 @@ def update_annotations_using_type_comments(
131131 app : Sphinx , obj : Any , bound_method : bool
132132) -> None :
133133 """Update annotations info of *obj* using type_comments."""
134+ if not app .config .autodoc_use_type_comments :
135+ return
136+
134137 try :
135138 type_sig = get_type_comment (obj , bound_method )
136139 if type_sig :
@@ -152,6 +155,9 @@ def update_annotations_using_type_comments(
152155
153156
154157def setup (app : Sphinx ) -> ExtensionMetadata :
158+ app .add_config_value (
159+ 'autodoc_use_type_comments' , True , 'env' , types = frozenset ({bool })
160+ )
155161 app .connect (
156162 'autodoc-before-process-signature' , update_annotations_using_type_comments
157163 )
You can’t perform that action at this time.
0 commit comments