Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygoodAlexWaygood commented Apr 19, 2024

…`get_type_hints`` (python#118009) (cherry-picked from commit 1e3e7ce) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@AlexWaygoodAlexWaygood enabled auto-merge (squash) April 19, 2024 13:31
@AlexWaygoodAlexWaygood merged commit 5430f61 into python:3.12Apr 19, 2024
@AlexWaygoodAlexWaygood deleted the backport-114053-312 branch April 19, 2024 13:41
AA-Turner pushed a commit to sphinx-doc/sphinx that referenced this pull request Apr 23, 2024
Python has recently [1] changed the signature of `_evaluate` for forward references because of type parameters. The change affects 3.13, and was backported to 3.12.4. [1]: python/cpython#118104
vfazio added a commit to vfazio/pydantic that referenced this pull request Jun 10, 2024
In CPython 3.12.4/3.13, the function signature of `FutureRef._evaluate` changed such that `recursive_guard` is no longer a positional argument; it is now keyword only [0][1]. To accomodate this, specify `recursive_guard` as a kwarg. This syntax is backwards compatible with earlier versions of the function signature. [0]: python/cpython#118104 [1]: python/cpython#118009 Signed-off-by: Vincent Fazio <vfazio@gmail.com>
vfazio added a commit to vfazio/pydantic that referenced this pull request Jun 10, 2024
In CPython 3.12.4/3.13, the function signature of `FutureRef._evaluate` changed such that `recursive_guard` is no longer a positional argument; it is now keyword only [0][1]. To accommodate this, specify `recursive_guard` as a kwarg. This syntax is backwards compatible with earlier versions of the function signature. [0]: python/cpython#118104 [1]: python/cpython#118009 Signed-off-by: Vincent Fazio <vfazio@gmail.com>
@dimaqq
Copy link
Contributor

This change causes a regression in some, admittedly rather old code.
Discussion is here: https://discuss.python.org/t/3-12-3-3-12-4-regression-deep-rabbit-hole-warning/59584/12

@AlexWaygood
Copy link
MemberAuthor

This change causes a regression in some, admittedly rather old code. Discussion is here: discuss.python.org/t/3-12-3-3-12-4-regression-deep-rabbit-hole-warning/59584/12

Sorry to hear that. It's pretty unclear to me what exactly the regression is from skimming that Discourse thread, however, and I'm a little low on time right now. Would you be able to create an issue with a minimal, reproducible example?

@dimaqq
Copy link
Contributor

I have a rather small MRE here: https://github.com/dimaqq/MRE-sphinx-PurePath

  • 3 small user files
  • uses Sphinx 6.2.1 + autodoc + basic extensions

I haven't gotten deep into Sphinx and how it uses the type system, there would probably be a lot to learn there...

MRE summary

Given this code:

importtypingfrompathlibimportPurePathfromtypingimportBinaryIO, Optional, TextIO, UnionclassContainer: """blah"""# This is OK (assuming intersphinx is set up)defanother(self, path: Union[str, PurePath], *, encoding: Optional[str] ='utf-8'): """a docstring"""# In the type overload specifically, the `path` argument type is broken under py 3.12.4@typing.overloaddefpull(self, path: Union[str, PurePath], *, encoding: str='utf-8') ->TextIO: ... # Sphinx seems to ignore this signature if there is a type overloaddefpull(self, path: Union[str, PurePath], *, encoding: Optional[str] ='utf-8'): """a docstring"""

Trying to build docs for this code with Sphinx 6.2.1 works under py 3.12.3 and fails under 3.12.4, whith this PR being the breaking change (confirmed by git bisect).

@dimaqq
Copy link
Contributor

dimaqq commented Aug 2, 2024

Daniel has tracked it down to function signature change for ForwardRef._evaluate here:

https://discuss.python.org/t/3-12-3-3-12-4-regression-deep-rabbit-hole-warning/59584/14

Whether the change is required or a regression is something I’m not qualified to have an opinion on, and will gladly leave to Python devs.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@AlexWaygood@dimaqq