Skip to content

Commit

Permalink
Fixes an annotation which was too strict.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daverball committed Feb 7, 2024
1 parent 5e4dbc2 commit 7afd43e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
---------

- Fixes another incorrect type annotation in `Scheduler`.
[Daverball]

0.7.1 (2024-01-18)
~~~~~~~~~~~~~~~~~~~

Expand Down
19 changes: 10 additions & 9 deletions src/libres/db/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import typing as _t
if _t.TYPE_CHECKING:
from sedate.types import DateLike
from sqlalchemy.orm import Query
from typing_extensions import NotRequired, Self, TypeAlias, TypedDict

Expand Down Expand Up @@ -893,8 +894,8 @@ def remove_allocation(

def remove_unused_allocations(
self,
start: datetime,
end: datetime,
start: 'DateLike',
end: 'DateLike',
days: _t.Optional[_t.Iterable[_t.Union['Day', 'DayNumber']]] = None,
exclude_groups: bool = False
) -> int:
Expand All @@ -916,7 +917,7 @@ def remove_unused_allocations(
be excluded, regardless of what this parameter is set to.
"""

start, end = self._prepare_range(
start_dt, end_dt = self._prepare_range(
sedate.as_datetime(start),
sedate.as_datetime(end)
)
Expand Down Expand Up @@ -957,22 +958,22 @@ def remove_unused_allocations(
groups = groups.having(
and_(
func.count(Allocation.id) == 1,
start <= func.min(Allocation._start),
func.max(Allocation._end) <= end
start_dt <= func.min(Allocation._start),
func.max(Allocation._end) <= end_dt
)
)
else:
groups = groups.having(
and_(
start <= func.min(Allocation._start),
func.max(Allocation._end) <= end
start_dt <= func.min(Allocation._start),
func.max(Allocation._end) <= end_dt
)
)

# all allocations
candidates = self.managed_allocations()
candidates = candidates.filter(start <= Allocation._start)
candidates = candidates.filter(Allocation._end <= end)
candidates = candidates.filter(start_dt <= Allocation._start)
candidates = candidates.filter(Allocation._end <= end_dt)

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

0 comments on commit 7afd43e

Please sign in to comment.