Skip to content

Commit dd4a357

Browse files
authored
Fix ty error and suppress warnings (#150)
* fix unsupported-operator error * suppress possibly-missing-attribute warnings
1 parent 81765cf commit dd4a357

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fsrs/scheduler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def get_card_retrievability(
219219
float: The retrievability of the Card object.
220220
"""
221221

222-
if card.last_review is None:
222+
if card.last_review is None or card.stability is None:
223223
return 0
224224

225225
if current_datetime is None:
@@ -658,7 +658,9 @@ def _next_interval(self, *, stability: float) -> int:
658658
)
659659

660660
if not isinstance(next_interval, Real): # type(next_interval) is torch.Tensor
661-
next_interval = next_interval.detach().item()
661+
next_interval = (
662+
next_interval.detach().item() # ty: ignore[possibly-missing-attribute]
663+
)
662664

663665
next_interval = round(next_interval) # intervals are full days
664666

@@ -679,7 +681,7 @@ def _short_term_stability(self, *, stability: float, rating: Rating) -> float:
679681
if isinstance(short_term_stability_increase, Real):
680682
short_term_stability_increase = max(short_term_stability_increase, 1.0)
681683
else: # type(short_term_stability_increase) is torch.Tensor
682-
short_term_stability_increase = short_term_stability_increase.clamp(
684+
short_term_stability_increase = short_term_stability_increase.clamp( # ty: ignore[possibly-missing-attribute]
683685
min=1.0
684686
)
685687

0 commit comments

Comments
 (0)