-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Python 3.14: bump fractions stubs #14215
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
Conversation
This comment has been minimized.
This comment has been minimized.
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 |
There was a problem hiding this 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.
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] |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Bump stubs for
fractions.Fractions
(py314). According to this comment, it will be relevant just to putmodulo
as None for__pow__
and__rpow__
.