Skip to content

Conversation

@Gogowitsch
Copy link

When trying to follow pandas-dev/pandas#55498, mypy complaines

error: Argument 1 to "Timedelta" has incompatible type "Minute | Hour | Day"; expected "str | float | Timedelta | timedelta | timedelta64[timedelta | int | None]" [arg-type]

The pandas source code checks if the value parameter is a Tick object (is_tick_object)

This is my first PR to this project. Question to reviewers: Shall I also open a PR to the pandas main repo to update the docstring to improve the documentation?

  • Closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added (Please use assert_type() to assert the type of any return value)
  • If I used AI to develop this pull request, I prompted it to follow AGENTS.md.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Please make these changes and then I will do the CI

Comment on lines +113 to +115
tick = Minute(15)
seconds = pd.Timedelta(tick).total_seconds()
assert seconds == 900.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

The test should be of the form:

check(assert_type(pd.Timedelta(Minute(15)), pd.Timedelta), pd.Timedelta)

from pandas._libs.tslibs import NaTType
from pandas._libs.tslibs import (
NaTType,
Tick,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should import Tick from pandas.tseries.offsets

from typing_extensions import assert_type

from pandas._libs import NaTType
from pandas._libs.tslibs.offsets import Minute
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should import Minute from pandas.tseries.offsets

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Jan 22, 2026

Question to reviewers: Shall I also open a PR to the pandas main repo to update the docstring to improve the documentation?

Yes, please!!

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.

2 participants