Skip to content

Add py.typed marker for PEP 561 support (#151)#153

Merged
asukaminato0721 merged 2 commits intoopen-spaced-repetition:mainfrom
qiinori:main
Mar 3, 2026
Merged

Add py.typed marker for PEP 561 support (#151)#153
asukaminato0721 merged 2 commits intoopen-spaced-repetition:mainfrom
qiinori:main

Conversation

@qiinori
Copy link
Contributor

@qiinori qiinori commented Feb 17, 2026

  • Add PEP 561 py.typed marker file so type checkers (pyright/pylance) recognize the package as typed

  • Configure pyproject.toml to include py.typed in the distribution

Closes #151

@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.73%. Comparing base (dd4a357) to head (5915c22).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
fsrs/scheduler.py 70.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #153      +/-   ##
==========================================
- Coverage   98.62%   97.73%   -0.90%     
==========================================
  Files           7        7              
  Lines         653      661       +8     
==========================================
+ Hits          644      646       +2     
- Misses          9       15       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@L-M-Sherlock
Copy link
Member

It hasn't passed the ci.

@asukaminato0721
Copy link
Contributor

https://pytorch.org/blog/pyrefly-now-type-checks-pytorch/

so actually I recommend pyrefly (

#149

@qiinori
Copy link
Contributor Author

qiinori commented Mar 1, 2026

It hasn't passed the ci.

Hi! Fixed — ty 0.0.17 reclassified union attribute access from possibly-missing-attribute, so the ignore directives needed updating. Pushed the fix, CI needs approval to run.

@qiinori
Copy link
Contributor Author

qiinori commented Mar 1, 2026

https://pytorch.org/blog/pyrefly-now-type-checks-pytorch/

so actually I recommend pyrefly (

#149

I can give pyrefly a try. Happy to fix them and switch to pyrefly in this PR if you'd like, or we can leave that for #149.

@asukaminato0721
Copy link
Contributor

try switch, let's see the results.

Since for now too many ignore

- Replace ty with pyrefly in dev deps, CI workflow, and pyproject config
- Add @overload on _clamp_difficulty/_clamp_stability for proper float/Tensor typing
- Replace isinstance(x, Real) with isinstance(x, (int, float)) for pyrefly narrowing
- Add wildcard match branches for exhaustive pattern checking
- Remove all type ignore comments (0 errors, 0 suppressed)
@qiinori
Copy link
Contributor Author

qiinori commented Mar 2, 2026

try switch, let's see the results.

Since for now too many ignore

Hi! I've pushed the transition from ty to pyrefly now. Eliminates all 4 ignore comments.

Code changes in fsrs/scheduler.py:

  • Added @overload on _clamp_difficulty and _clamp_stability to type the dual float/torch.Tensor paths, letting pyrefly validate torch. Tensor methods like .clamp() in the else branch — eliminates all 4 ignore comments
  • Replaced isinstance(x, Real) with isinstance(x, (int, float)) so pyrefly can narrow the else branch to torch. Tensor
  • Added TYPE_CHECKING-gated from torch import Tensor (torch is optional; no runtime cost)
  • Added wildcard case _: branches — IntEnum inherits int, so pyrefly can't prove exhaustiveness
  • Added float() cast in _get_fuzz_range for mixed-type min() overload resolution

Code changes in pyproject.toml:

  • switch ty with pyrefly in dev deps and tool config
  • Added ignore-missing-imports = ["torch"] so pyrefly doesn't error on the optional torch dependency

Code changes in .github/workflows/type-check.yml:

  • switch ty with pyrefly in install and run steps

@asukaminato0721
Copy link
Contributor

asukaminato0721 commented Mar 2, 2026

@asukaminato0721
Copy link
Contributor

asukaminato0721 commented Mar 2, 2026

ERROR `next_interval` may be uninitialized [unbound-name]
   --> fsrs/scheduler.py:497:64
    |
497 |             next_interval = self._get_fuzzed_interval(interval=next_interval)
    |                                                                ^^^^^^^^^^^^^
    |
ERROR `next_interval` may be uninitialized [unbound-name]
   --> fsrs/scheduler.py:499:38
    |
499 |         card.due = review_datetime + next_interval
    |                                      ^^^^^^^^^^^^^
    |
 INFO 2 errors

sorry I found the problem, could you drop my two commits.

And we will merge this.

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Mar 3, 2026
Merged via the queue into open-spaced-repetition:main with commit a3804a6 Mar 3, 2026
12 checks passed
@qiinori
Copy link
Contributor Author

qiinori commented Mar 3, 2026

ERROR ``next_interval`` may be uninitialized [unbound-name]
   --> fsrs/scheduler.py:497:64
    |
497 |             next_interval = self._get_fuzzed_interval(interval=next_interval)
    |                                                                ^^^^^^^^^^^^^
    |
ERROR ``next_interval`` may be uninitialized [unbound-name]
   --> fsrs/scheduler.py:499:38
    |
499 |         card.due = review_datetime + next_interval
    |                                      ^^^^^^^^^^^^^
    |
 INFO 2 errors

sorry I found the problem, could you drop my two commits.

And we will merge this.

Thanks for the approval!

@ishiko732
Copy link
Member

Could you update the version here?

version = "6.3.0"

The new release depends on this version number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

missing a py.typed file

4 participants