File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
pandas-stubs/_libs/tslibs Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ from pandas.core.series import (
24
24
TimestampSeries ,
25
25
)
26
26
from typing_extensions import (
27
+ Never ,
27
28
Self ,
28
29
TypeAlias ,
29
30
)
@@ -146,7 +147,7 @@ class Timestamp(datetime):
146
147
def ctime (self ) -> str : ...
147
148
def isoformat (self , sep : str = ..., timespec : str = ...) -> str : ...
148
149
@classmethod
149
- def strptime (cls , date_string : str , format : str ) -> datetime : ...
150
+ def strptime (cls , date_string : Never , format : Never ) -> Never : ... # type: ignore[override]
150
151
def utcoffset (self ) -> timedelta | None : ...
151
152
def tzname (self ) -> str | None : ...
152
153
def dst (self ) -> timedelta | None : ...
Original file line number Diff line number Diff line change 13
13
from numpy import typing as npt
14
14
import pandas as pd
15
15
import pytz
16
- from typing_extensions import assert_type
16
+ from typing_extensions import (
17
+ assert_never ,
18
+ assert_type ,
19
+ )
17
20
18
21
from pandas ._libs import NaTType
19
22
from pandas ._libs .tslibs import BaseOffset
@@ -1122,3 +1125,13 @@ def test_mean_median_std() -> None:
1122
1125
check (assert_type (s2 .mean (), pd .Timestamp ), pd .Timestamp )
1123
1126
check (assert_type (s2 .median (), pd .Timestamp ), pd .Timestamp )
1124
1127
check (assert_type (s2 .std (), pd .Timedelta ), pd .Timedelta )
1128
+
1129
+
1130
+ def test_timestamp_strptime_fails ():
1131
+ if TYPE_CHECKING_INVALID_USAGE :
1132
+ assert_never (
1133
+ pd .Timestamp .strptime (
1134
+ "2023-02-16" , # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues]
1135
+ "%Y-%M-%D" , # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues]
1136
+ )
1137
+ )
You can’t perform that action at this time.
0 commit comments