Skip to content

Commit

Permalink
docs(temporal): add Literal annotation to display possible units fo…
Browse files Browse the repository at this point in the history
…r `delta` method
  • Loading branch information
cpcloud authored and gforsyth committed Nov 10, 2023
1 parent ed3b017 commit ee94cb5
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions ibis/expr/types/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ee94cb5

Please sign in to comment.