Skip to content

Commit

Permalink
Link more issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 31, 2024
1 parent f27a2db commit 2ec684b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tempora/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def ensure_datetime(ob: AnyDatetime) -> datetime.datetime:

def infer_datetime(ob: AnyDatetime | StructDatetime) -> datetime.datetime:
if isinstance(ob, (time.struct_time, tuple)):
ob = datetime.datetime(*ob[:6]) # type: ignore[arg-type]
year, month, day, hour, minute, second, *_ = ob
ob = datetime.datetime(year, month, day, hour, minute, second)
return ensure_datetime(ob)


Expand Down
4 changes: 2 additions & 2 deletions tempora/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class PeriodicCommandFixedDelay(PeriodicCommand):
"""

@classmethod
def at_time(cls, at, delay, target) -> Self: # type: ignore[override]
def at_time(cls, at, delay, target) -> Self: # type: ignore[override] # jaraco/tempora#39
"""
>>> cmd = PeriodicCommandFixedDelay.at_time(0, 30, None)
>>> cmd.delay.total_seconds()
Expand All @@ -137,7 +137,7 @@ def at_time(cls, at, delay, target) -> Self: # type: ignore[override]
at = cls._from_timestamp(at)
cmd = cls.from_datetime(at)
if isinstance(delay, numbers.Number):
delay = datetime.timedelta(seconds=delay) # type: ignore[arg-type]
delay = datetime.timedelta(seconds=delay) # type: ignore[arg-type] # python/mypy#3186#issuecomment-1571512649
cmd.delay = delay
cmd.target = target
return cmd
Expand Down
12 changes: 7 additions & 5 deletions tempora/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class IntervalGovernor:

def __init__(self, min_interval) -> None:
if isinstance(min_interval, numbers.Number):
min_interval = datetime.timedelta(seconds=min_interval) # type: ignore[arg-type]
min_interval = datetime.timedelta(seconds=min_interval) # type: ignore[arg-type] # python/mypy#3186#issuecomment-1571512649
self.min_interval = min_interval
self.last_call = None

Expand Down Expand Up @@ -248,23 +248,25 @@ def __init__(
) -> None:
self.delay = delay
self.factor = factor
if isinstance(limit, (numbers.Number, int, float)):
if isinstance(limit, numbers.Number):
limit_ = limit

def limit_func(n: float, /) -> float:
return max(0, min(limit_, n))

else:
limit_func = limit
# python/mypy#16946 or # python/mypy#13914
limit_func: collections.abc.Callable[[float], float] = limit # type: ignore[no-redef]
self.limit = limit_func
if isinstance(jitter, (numbers.Number, int, float)):
if isinstance(jitter, numbers.Number):
jitter_ = jitter

def jitter_func() -> float:
return jitter_

else:
jitter_func = jitter
# python/mypy#16946 or # python/mypy#13914
jitter_func: collections.abc.Callable[[], float] = jitter # type: ignore[no-redef]

self.jitter = jitter_func

Expand Down

0 comments on commit 2ec684b

Please sign in to comment.