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

Typing: More precise NaT stub #60002

Merged
merged 3 commits into from
Oct 8, 2024

Conversation

randolf-scholz
Copy link
Contributor

@randolf-scholz randolf-scholz commented Oct 8, 2024

  • marked arguments in dunder methods positional only
    (important for subclassing and protocols)

  • added Period, np.datetime64 and np.timedelta64 as compatible for __add__ and __sub__

  • added np.datetime64 and np.timedelta64 as compatible with __floordiv__ and __truediv__

  • reworked comparisons:

    • removed protocol and use plain definition
    • changed return type from bool to Literal[False]
    • added Self to comparable types, so that pd.NaT > pd.NaT is considered valid
  • closes TYP: More precise NaT stubs #60003 (Replace xxxx with the GitHub issue number)

  • Tests added and passed if fixing a bug or adding a new feature

  • All code checks passed.

  • Added type annotations to new arguments/methods/functions.

  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@randolf-scholz randolf-scholz changed the title Mmore precise NaT stub More precise NaT stub Oct 8, 2024
@randolf-scholz randolf-scholz changed the title More precise NaT stub Typing: More precise NaT stub Oct 8, 2024
@randolf-scholz randolf-scholz marked this pull request as ready for review October 8, 2024 10:30
@mroeschke mroeschke added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Typing type annotations, mypy/pyright type checking labels Oct 8, 2024
@mroeschke mroeschke added this to the 3.0 milestone Oct 8, 2024
@mroeschke mroeschke merged commit 5ea5bd9 into pandas-dev:main Oct 8, 2024
55 checks passed
@mroeschke
Copy link
Member

Thanks @randolf-scholz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TYP: More precise NaT stubs
2 participants