Description
Since Sphinx v7.3.0, there is a warning about config values that are not pickleable. When building with warning_is_error = True
, this fails the build. See sphinx-doc/sphinx#12300 for context.
For sphinx-autodoc-typehints, this means that a custom typehints_formatter
leads to a build failure.
To reproduce, simply use this conf.py
:
project = 'custom_formatter'
extensions = [
'sphinx.ext.autodoc',
'sphinx_autodoc_typehints',
]
warning_is_error = True
show_warning_types = True
def formatter(annotation, config):
return None
typehints_formatter = formatter
It results in this warning:
sphinx.errors.SphinxWarning: cannot cache unpickable configuration value: 'typehints_formatter' (because it contains a function, class, or module object) [config.cache]
Apart from triggering a warning that needs to be silenced, this also prevents caching. So it would be great to have a solution that avoids specifying a callable as typehints_formatter
. One option would be using a fully qualified path and make sphinx-autodoc-typehints import a function from that path. E.g. typehints_formatter = 'mypackage.sphinxext.typehints_formatter'
. See also this comment: sphinx-doc/sphinx#12300 (comment)