From 8c8889d6c5df12cf67125fdc4ba5732aeaa2c3e8 Mon Sep 17 00:00:00 2001 From: Brock Date: Sat, 22 May 2021 11:25:39 -0700 Subject: [PATCH 1/2] TYP: NaTType comparisons --- pandas/_libs/tslibs/nattype.pyi | 35 ++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/nattype.pyi b/pandas/_libs/tslibs/nattype.pyi index 0f81dcb4b2df1..7164f9eec020c 100644 --- a/pandas/_libs/tslibs/nattype.pyi +++ b/pandas/_libs/tslibs/nattype.pyi @@ -1,8 +1,14 @@ -from datetime import datetime +from datetime import ( + datetime, + timedelta, +) +from typing import Any import numpy as np +from pandas._libs.tslibs.period import Period + NaT: NaTType iNaT: int nat_strings: set[str] @@ -133,3 +139,30 @@ class NaTType(datetime): # inject Period properties @property def qyear(self) -> float: ... + + def __eq__(self, other: Any) -> bool: ... + def __ne__(self, other: Any) -> bool: ... + # error: Argument 1 of "__lt__" is incompatible with supertype "date"; + # supertype defines the argument type as "date" + def __lt__( # type: ignore[override] + self, + other: datetime | timedelta | Period | np.datetime64 | np.timedelta64 + ) -> bool: ... + # error: Argument 1 of "__le__" is incompatible with supertype "date"; + # supertype defines the argument type as "date" + def __le__( # type: ignore[override] + self, + other: datetime | timedelta | Period | np.datetime64 | np.timedelta64 + ) -> bool: ... + # error: Argument 1 of "__gt__" is incompatible with supertype "date"; + # supertype defines the argument type as "date" + def __gt__( # type: ignore[override] + self, + other: datetime | timedelta | Period | np.datetime64 | np.timedelta64 + ) -> bool: ... + # error: Argument 1 of "__ge__" is incompatible with supertype "date"; + # supertype defines the argument type as "date" + def __ge__( # type: ignore[override] + self, + other: datetime | timedelta | Period | np.datetime64 | np.timedelta64 + ) -> bool: ... From 603a04da1cb56fb4a861fa12801228070e1c92e4 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sun, 23 May 2021 10:32:48 -0700 Subject: [PATCH 2/2] Update pandas/_libs/tslibs/nattype.pyi Co-authored-by: Simon Hawkins --- pandas/_libs/tslibs/nattype.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/_libs/tslibs/nattype.pyi b/pandas/_libs/tslibs/nattype.pyi index 7164f9eec020c..5a2985d0e815b 100644 --- a/pandas/_libs/tslibs/nattype.pyi +++ b/pandas/_libs/tslibs/nattype.pyi @@ -142,6 +142,7 @@ class NaTType(datetime): def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... + # https://github.com/python/mypy/issues/9015 # error: Argument 1 of "__lt__" is incompatible with supertype "date"; # supertype defines the argument type as "date" def __lt__( # type: ignore[override]