3.12.3 --> 3.12.4 regression? [deep rabbit hole warning]

The regression seems to be basically that Sphix 6.2.1 tried to run code equivalent to below for overloads, and that works in 3.12.3 and doesn’t in 3.12.4 due to a signature change:

import typing
annotation = 'Union[str, PurePath]'
fr = typing.ForwardRef(annotation, True)
print(fr._evaluate(globals(), locals(), frozenset())) 

# There is a new argument in 3.12.4
# The new signature is: _evaluate(self, globalns, localns, type_params, *, recursive_guard)

This happens in sphinx.util.inspect.evaluate_signature, which is called by sphinx.ext.autodoc.MethodDocumenter.format_signature to handle overloads. That function has an exception guard that results in the signature remaining a string instead of a becoming a type.

I think that’s it. You can test this by editing evaluate_forwardref inside sphinx.util.inspect.evaluate_signature and adding an if branch for 3.12.4 to call ref._evaluate with the correct arguments.

3 Likes