8000 Python 3.14: bump fractions stubs by hrimov · Pull Request #14215 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Python 3.14: bump fractions stubs #14215

8000
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

Merged
merged 3 commits into from
Jun 3, 2025
Merged

Conversation

hrimov
Copy link
Contributor
@hrimov hrimov commented Jun 3, 2025

Bump stubs for fractions.Fractions (py314). According to this comment, it will be relevant just to put modulo as None for __pow__ and __rpow__.

This comment has been minimized.

@donBarbos
Copy link
Contributor

Thank you! I'll just add that a PR #14070 has recently arrived, but the author decided to close it, so I think it will be possible to accept your PR

Copy link
Collaborator
@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good, just some comments about the tests.

Comment on lines 91 to 94
if sys.version_info >= (3, 14):
assert_type(pow(Fraction(3, 4), 2, None), Fraction) # pyright: ignore[reportAssertTypeFailure]
assert_type(pow(Fraction(3, 4), 2, "Non-none value"), Any) # type: ignore[misc]
assert_type(pow(Fraction(3, 4), 2, True), Any) # type: ignore[misc]
8000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does pyright report an error for the first test? And why doesn't it for the second? There should be at least a comment explaining why pyright doesn't work correctly.

The second and third tests basically test the same. It would also make more sense to use a "more expected" type like an integer. That a string would cause problems is kind of a given. Also, the assert_type in tests that we expect to fail doesn't make much sense.

We should also keep the old test for Python < 3.14:

Suggested change
if sys.version_info >= (3, 14):
assert_type(pow(Fraction(3, 4), 2, None), Fraction) # pyright: ignore[reportAssertTypeFailure]
assert_type(pow(Fraction(3, 4), 2, "Non-none value"), Any) # type: ignore[misc]
assert_type(pow(Fraction(3, 4), 2, True), Any) # type: ignore[misc]
if sys.version_info >= (3, 14):
assert_type(pow(Fraction(3, 4), 2, None), Fraction) # pyright: ignore[reportAssertTypeFailure]
pow(Fraction(3, 4), 2, 1) # type: ignore[misc]
else:
pow(Fraction(), 5, 8) # type: ignore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second and third tests basically test the same. It would also make more sense to use a "more expected" type like an integer. That a string would cause problems is kind of a given. Also, the assert_type in tests that we expect to fail doesn't make much sense.

We should also keep the old test for Python < 3.14:

Got it, thx! Regarding the pyright-specific ignore - it was already described it this test-file, its due to the more complex inferred type, rather than Fraction, so I just moved that comment below.

@hrimov hrimov requested a review from srittau June 3, 2025 17:43
Copy link
Contributor
github-actions bot commented Jun 3, 2025

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit 567b488 into python:main Jun 3, 2025
64 checks passed
@hrimov hrimov deleted the python314/fractions branch June 3, 2025 18:36
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.

< 3751 /div>
3 participants
0