Skip to content

Commit 827a9fe

Browse files
authored
test: propagate pandas-dev/pandas#39196
1 parent 0b13dc8 commit 827a9fe

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/scalars/test_scalars.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,3 +1845,26 @@ def test_period_methods() -> None:
18451845
def test_nattype_hashable() -> None:
18461846
# GH 827
18471847
check(assert_type(pd.NaT.__hash__(), int), int)
1848+
1849+
1850+
def test_nat_comparison_with_date() -> None:
1851+
# 2.0.0: inequality comparisons of NaT with datetime.date now raise TypeError
1852+
# pandas-dev/pandas#39196
1853+
date_obj = datetime.date(2023, 1, 1)
1854+
1855+
# Equality comparisons should still work
1856+
check(assert_type(pd.NaT == date_obj, bool), bool)
1857+
check(assert_type(pd.NaT != date_obj, bool), bool)
1858+
check(assert_type(date_obj == pd.NaT, bool), bool)
1859+
check(assert_type(date_obj != pd.NaT, bool), bool)
1860+
1861+
# Inequality comparisons should raise TypeError
1862+
if TYPE_CHECKING_INVALID_USAGE:
1863+
_llt = pd.NaT < date_obj # type: ignore[arg-type] # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
1864+
_lgt = pd.NaT > date_obj # type: ignore[arg-type] # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
1865+
_lle = pd.NaT <= date_obj # type: ignore[arg-type] # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
1866+
_lge = pd.NaT >= date_obj # type: ignore[arg-type] # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
1867+
_rlt = date_obj < pd.NaT # type: ignore[operator] # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
1868+
_rgt = date_obj > pd.NaT # type: ignore[operator] # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
1869+
_rle = date_obj <= pd.NaT # type: ignore[operator] # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
1870+
_rge = date_obj >= pd.NaT # type: ignore[operator] # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]

0 commit comments

Comments
 (0)