Skip to content

Commit 7afd43e

Browse files
committed
Fixes an annotation which was too strict.
1 parent 5e4dbc2 commit 7afd43e

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

HISTORY.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Changelog
22
---------
33

4+
- Fixes another incorrect type annotation in `Scheduler`.
5+
[Daverball]
6+
47
0.7.1 (2024-01-18)
58
~~~~~~~~~~~~~~~~~~~
69

src/libres/db/scheduler.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import typing as _t
2020
if _t.TYPE_CHECKING:
21+
from sedate.types import DateLike
2122
from sqlalchemy.orm import Query
2223
from typing_extensions import NotRequired, Self, TypeAlias, TypedDict
2324

@@ -893,8 +894,8 @@ def remove_allocation(
893894

894895
def remove_unused_allocations(
895896
self,
896-
start: datetime,
897-
end: datetime,
897+
start: 'DateLike',
898+
end: 'DateLike',
898899
days: _t.Optional[_t.Iterable[_t.Union['Day', 'DayNumber']]] = None,
899900
exclude_groups: bool = False
900901
) -> int:
@@ -916,7 +917,7 @@ def remove_unused_allocations(
916917
be excluded, regardless of what this parameter is set to.
917918
"""
918919

919-
start, end = self._prepare_range(
920+
start_dt, end_dt = self._prepare_range(
920921
sedate.as_datetime(start),
921922
sedate.as_datetime(end)
922923
)
@@ -957,22 +958,22 @@ def remove_unused_allocations(
957958
groups = groups.having(
958959
and_(
959960
func.count(Allocation.id) == 1,
960-
start <= func.min(Allocation._start),
961-
func.max(Allocation._end) <= end
961+
start_dt <= func.min(Allocation._start),
962+
func.max(Allocation._end) <= end_dt
962963
)
963964
)
964965
else:
965966
groups = groups.having(
966967
and_(
967-
start <= func.min(Allocation._start),
968-
func.max(Allocation._end) <= end
968+
start_dt <= func.min(Allocation._start),
969+
func.max(Allocation._end) <= end_dt
969970
)
970971
)
971972

972973
# all allocations
973974
candidates = self.managed_allocations()
974-
candidates = candidates.filter(start <= Allocation._start)
975-
candidates = candidates.filter(Allocation._end <= end)
975+
candidates = candidates.filter(start_dt <= Allocation._start)
976+
candidates = candidates.filter(Allocation._end <= end_dt)
976977

977978
# .. without the ones with slots
978979
candidates = candidates.filter(not_(Allocation.id.in_(slots)))

0 commit comments

Comments
 (0)