You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
foo.py:7: error: Argument "freq" to "timedelta_range" has incompatible type "Timedelta"; expected "Union[str, DateOffset, None]" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Please complete the following information:
OS: Debian 11.6
Python: 3.9.2
mypy: 1.1.1
pandas: 1.5.3
pandas-stubs: 1.5.3.230321
Additional context #223 mentions date_range and bdate_range.
pandas-dev/pandas#48631 updates the documentation for date_range, bdate_range, and interval_range.
#322 updates the stubs for date_range and bdate_range.
However, using Timedelta or timedelta with timedelta_range seems to work as well. (I'm not sure I fully understand the difference between Timedelta and DateOffset, but I don't see why a Timedelta shouldn't be accepted here.)
The text was updated successfully, but these errors were encountered:
We generally follow a policy that the stubs follow what is documented for pandas.
So before we change the stubs, we should get agreement from the pandas maintainers that Timedelta and timedelta are supposed to be allowed with timedelta_range() and interval_range(). Can you open a doc issue in the pandas project there and cross-reference to here, so we can track that?
The documentation has now been updated (thanks to @allisonkwan for the quick response.)
Great. Now someone can do a PR to update the stubs here for date_range(), interval_range(), bdate_range(), and timedelta_range(), with appropriate tests.
Describe the bug
The
timedelta_range
andinterval_range
functions should accept apandas.Timedelta
ordatetime.timedelta
object as thefreq
argument.To Reproduce
Example:
Using
mypy foo.py
:Please complete the following information:
Additional context
#223 mentions
date_range
andbdate_range
.pandas-dev/pandas#48631 updates the documentation for
date_range
,bdate_range
, andinterval_range
.#322 updates the stubs for
date_range
andbdate_range
.However, using
Timedelta
ortimedelta
withtimedelta_range
seems to work as well. (I'm not sure I fully understand the difference between Timedelta and DateOffset, but I don't see why a Timedelta shouldn't be accepted here.)The text was updated successfully, but these errors were encountered: