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 (
2424 TimestampSeries ,
2525)
2626from typing_extensions import (
27+ Never ,
2728 Self ,
2829 TypeAlias ,
2930)
@@ -146,7 +147,7 @@ class Timestamp(datetime):
146147 def ctime (self ) -> str : ...
147148 def isoformat (self , sep : str = ..., timespec : str = ...) -> str : ...
148149 @classmethod
149- def strptime (cls , date_string : str , format : str ) -> datetime : ...
150+ def strptime (cls , date_string : Never , format : Never ) -> Never : ... # type: ignore[override]
150151 def utcoffset (self ) -> timedelta | None : ...
151152 def tzname (self ) -> str | None : ...
152153 def dst (self ) -> timedelta | None : ...
Original file line number Diff line number Diff line change 1313from numpy import typing as npt
1414import pandas as pd
1515import pytz
16- from typing_extensions import assert_type
16+ from typing_extensions import (
17+ assert_never ,
18+ assert_type ,
19+ )
1720
1821from pandas ._libs import NaTType
1922from pandas ._libs .tslibs import BaseOffset
@@ -1122,3 +1125,13 @@ def test_mean_median_std() -> None:
11221125 check (assert_type (s2 .mean (), pd .Timestamp ), pd .Timestamp )
11231126 check (assert_type (s2 .median (), pd .Timestamp ), pd .Timestamp )
11241127 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