Skip to content

Commit

Permalink
fix: mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Jan 15, 2025
1 parent 1103dc2 commit e4b84d7
Showing 1 changed file with 34 additions and 38 deletions.
72 changes: 34 additions & 38 deletions src/safeds/data/tabular/containers/_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ def date(

from ._lazy_cell import _LazyCell # circular import

year = _unwrap(year)
month = _unwrap(month)
day = _unwrap(day)

return _LazyCell(pl.date(year, month, day))
return _LazyCell(
pl.date(
year=_unwrap(year),
month=_unwrap(month),
day=_unwrap(day),
),
)

@staticmethod
def datetime(
Expand Down Expand Up @@ -200,18 +202,18 @@ def datetime(

from ._lazy_cell import _LazyCell # circular import

year = _unwrap(year)
month = _unwrap(month)
day = _unwrap(day)
hour = _unwrap(hour)
minute = _unwrap(minute)
second = _unwrap(second)
microsecond = _unwrap(microsecond)
pl_year = _unwrap(year)
pl_month = _unwrap(month)
pl_day = _unwrap(day)
pl_hour = _unwrap(hour)
pl_minute = _unwrap(minute)
pl_second = _unwrap(second)
pl_microsecond = _unwrap(microsecond)

# By default, microseconds overflow into seconds
return _LazyCell(
pl.when(microsecond <= 999_999)
.then(pl.datetime(year, month, day, hour, minute, second, microsecond))
pl.when(pl_microsecond <= 999_999)
.then(pl.datetime(pl_year, pl_month, pl_day, pl_hour, pl_minute, pl_second, pl_microsecond))
.otherwise(None),
)

Expand Down Expand Up @@ -283,33 +285,25 @@ def duration(

from ._lazy_cell import _LazyCell # circular import

weeks = _unwrap(weeks)
days = _unwrap(days)
hours = _unwrap(hours)
minutes = _unwrap(minutes)
seconds = _unwrap(seconds)
milliseconds = _unwrap(milliseconds)
microseconds = _unwrap(microseconds)

return _LazyCell(
pl.duration(
weeks=weeks,
days=days,
hours=hours,
minutes=minutes,
seconds=seconds,
milliseconds=milliseconds,
microseconds=microseconds,
weeks=_unwrap(weeks),
days=_unwrap(days),
hours=_unwrap(hours),
minutes=_unwrap(minutes),
seconds=_unwrap(seconds),
milliseconds=_unwrap(milliseconds),
microseconds=_unwrap(microseconds),
),
)

@staticmethod
def time(
hour: int | Cell[int],
minute: int | Cell[int],
second: int | Cell[int],
hour: _ConvertibleToIntCell,
minute: _ConvertibleToIntCell,
second: _ConvertibleToIntCell,
*,
microsecond: int | Cell[int] = 0,
microsecond: _ConvertibleToIntCell = 0,
) -> Cell[python_datetime.time | None]:
"""
Create a cell with a time.
Expand Down Expand Up @@ -362,14 +356,16 @@ def time(

from ._lazy_cell import _LazyCell # circular import

hour = _unwrap(hour)
minute = _unwrap(minute)
second = _unwrap(second)
microsecond = _unwrap(microsecond)
pl_hour = _unwrap(hour)
pl_minute = _unwrap(minute)
pl_second = _unwrap(second)
pl_microsecond = _unwrap(microsecond)

# By default, microseconds overflow into seconds
return _LazyCell(
pl.when(microsecond <= 999_999).then(pl.time(hour, minute, second, microsecond)).otherwise(None),
pl.when(pl_microsecond <= 999_999)
.then(pl.time(pl_hour, pl_minute, pl_second, pl_microsecond))
.otherwise(None),
)

@staticmethod
Expand Down

0 comments on commit e4b84d7

Please sign in to comment.