File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -103,11 +103,6 @@ class BaseOffset:
103103class SingleConstructorOffset (BaseOffset ):
104104 def __reduce__ (self ): ...
105105
106- @overload
107- def to_offset (freq : None ) -> None : ...
108- @overload
109- def to_offset (freq : timedelta | BaseOffset | str ) -> BaseOffset : ...
110-
111106class Tick (SingleConstructorOffset ):
112107 def __init__ (self , n : int = ..., normalize : bool = ...) -> None : ...
113108 @property
Original file line number Diff line number Diff line change 1+ from typing import overload
2+
13from pandas import (
24 DatetimeIndex ,
35 Series ,
46 TimedeltaIndex ,
57)
68
7- from pandas .tseries .offsets import DateOffset as DateOffset
9+ from pandas ._typing import Frequency
10+
11+ from pandas .tseries .offsets import DateOffset
812
913def get_period_alias (offset_str : str ) -> str | None : ...
10- def to_offset (freq ) -> DateOffset | None : ...
14+ @overload
15+ def to_offset (freq : None ) -> None : ...
16+ @overload
17+ def to_offset (freq : Frequency ) -> DateOffset : ...
1118def get_offset (name : str ) -> DateOffset : ...
1219def infer_freq (index : Series | DatetimeIndex | TimedeltaIndex ) -> str | None : ...
Original file line number Diff line number Diff line change 2828
2929from pandas ._libs import NaTType
3030from pandas ._libs .tslibs import BaseOffset
31- from pandas ._libs .tslibs .offsets import DateOffset
31+
32+ from pandas .tseries .frequencies import to_offset
33+ from pandas .tseries .offsets import DateOffset
3234
3335if TYPE_CHECKING :
3436 from pandas ._typing import FulldatetimeDict
@@ -1425,3 +1427,8 @@ def test_DatetimeIndex_sub_timedelta() -> None:
14251427 ),
14261428 pd .DatetimeIndex ,
14271429 )
1430+
1431+
1432+ def test_to_offset () -> None :
1433+ check (assert_type (to_offset (None ), None ), type (None ))
1434+ check (assert_type (to_offset ("1D" ), DateOffset ), DateOffset )
You can’t perform that action at this time.
0 commit comments