Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TYP: Fix timedelta64.__divmod__ and timedelta64.__mod__ overloads #28259

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 2 commits into from
Feb 1, 2025

Conversation

jorenham
Copy link
Member

@jorenham jorenham commented Feb 1, 2025

Closes #28256, and fixes incorrect inference of timedelta64.__[div]mod__ if the right-hand-side is zero-ish.

@jorenham jorenham added 09 - Backport-Candidate PRs tagged should be backported 41 - Static typing labels Feb 1, 2025
@jorenham jorenham added this to the 2.2.3 release milestone Feb 1, 2025
Copy link

github-actions bot commented Feb 1, 2025

Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code:

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/arrays/timedeltas.py:328: note:     def [_TD64ItemT_co: timedelta | int | None] __init__(self, Literal[0], Literal['Y', 'M', b'Y', b'M', 'ns', 'ps', 'fs', 'as', b'ns', b'ps', b'fs', b'as'] | tuple[Literal['Y', 'M', b'Y', b'M', 'ns', 'ps', 'fs', 'as', b'ns', b'ps', b'fs', b'as'], SupportsIndex] = ..., /) -> timedelta64[Literal[0]]
+ pandas/tests/dtypes/test_missing.py:773: note:     def [_TD64ItemT_co: timedelta | int | None] __init__(self, Literal[0], Literal['Y', 'M', b'Y', b'M', 'ns', 'ps', 'fs', 'as', b'ns', b'ps', b'fs', b'as'] | tuple[Literal['Y', 'M', b'Y', b'M', 'ns', 'ps', 'fs', 'as', b'ns', b'ps', b'fs', b'as'], SupportsIndex] = ..., /) -> timedelta64[Literal[0]]

@charris charris merged commit 1553657 into numpy:main Feb 1, 2025
70 checks passed
@charris
Copy link
Member

charris commented Feb 1, 2025

Thanks Joren.

@jorenham jorenham deleted the typing/fix-28256 branch February 1, 2025 20:04
jorenham added a commit to numpy/numtype that referenced this pull request Feb 3, 2025
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TYP: timedelta64.__divmod__ incorrect inference
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.