Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-128661: Fix typing.evaluate_forward_ref not showing deprecation #128663

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 9, 2025

Now calling typing.evaluate_forward_ref without type_params raises a warning, as it should.
Calling ForwardRef._evaluate only raises 1 warning, as it should.

I've also covered all branches. After:
Снимок экрана 2025-01-09 в 12 04 04

No backports are needed, this is 3.14 only feature.

@AlexWaygood AlexWaygood changed the title gh-128661: Fix typing.evaluate_forward_ref not showing deprecataion gh-128661: Fix typing.evaluate_forward_ref not showing deprecation Jan 9, 2025
@sobolevn sobolevn merged commit b725297 into python:main Jan 9, 2025
44 checks passed
@JelleZijlstra
Copy link
Member

I don't think we should have done this; it makes the interface excessively clunky.

@sobolevn
Copy link
Member Author

@JelleZijlstra what's your opinion about the alternative?

@JelleZijlstra
Copy link
Member

The code was correct as is. Forcing people to write type_params=() to handle a rare edge case is not friendly to users.

@sobolevn
Copy link
Member Author

Hm, looks like other similar APIs also has this pattern. Like typing._eval_type and ForwardRef._evaluate.

I got confused by

cpython/Lib/typing.py

Lines 1053 to 1055 in 1b39b50

if type_params is _sentinel:
_deprecation_warning_for_no_type_params_passed("typing.evaluate_forward_ref")
type_params = ()
How can anybody pass _sentinel there, if it is not a default?

Sign up for free to 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.

3 participants