Skip to content

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

Merged
charris merged 2 commits intonumpy:mainfrom
jorenham:typing/fix-28256
Feb 1, 2025
Merged

TYP: Fix timedelta64.__divmod__ and timedelta64.__mod__ overloads#28259
charris merged 2 commits intonumpy:mainfrom
jorenham:typing/fix-28256

Conversation

@jorenham
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown

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
@charris
Copy link
Copy Markdown
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