From ee94cb547562c43a35a82f8d79cd1767b46112d1 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Fri, 10 Nov 2023 09:22:18 -0500 Subject: [PATCH] docs(temporal): add `Literal` annotation to display possible units for `delta` method --- ibis/expr/types/temporal.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/ibis/expr/types/temporal.py b/ibis/expr/types/temporal.py index f5cbc84b4ed9..f71c8aef7617 100644 --- a/ibis/expr/types/temporal.py +++ b/ibis/expr/types/temporal.py @@ -255,7 +255,12 @@ def __rsub__(self, other: ops.Value[dt.Interval | dt.Time, ds.Any]): rsub = __rsub__ def delta( - self, other: datetime.time | Value[dt.Time], part: str + self, + other: datetime.time | Value[dt.Time], + part: Literal[ + "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" + ] + | Value[dt.String], ) -> ir.IntegerValue: """Compute the number of `part`s between two times. @@ -401,7 +406,9 @@ def __rsub__(self, other: ops.Value[dt.Date | dt.Interval, ds.Any]): rsub = __rsub__ def delta( - self, other: datetime.date | Value[dt.Date], part: str + self, + other: datetime.date | Value[dt.Date], + part: Literal["year", "quarter", "month", "week", "day"] | Value[dt.String], ) -> ir.IntegerValue: """Compute the number of `part`s between two dates. @@ -678,7 +685,22 @@ def __rsub__(self, other: ops.Value[dt.Timestamp | dt.Interval, ds.Any]): rsub = __rsub__ def delta( - self, other: datetime.datetime | Value[dt.Timestamp], part: str + self, + other: datetime.datetime | Value[dt.Timestamp], + part: Literal[ + "year", + "quarter", + "month", + "week", + "day", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + ] + | Value[dt.String], ) -> ir.IntegerValue: """Compute the number of `part`s between two timestamps.