Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type hinting for lru_cache on methods #105

Merged
merged 13 commits into from
Apr 30, 2023
Merged

Conversation

maxfischer2781
Copy link
Owner

@maxfischer2781 maxfischer2781 commented Mar 21, 2023

This PR improves the type hinting of lru_cache. Major changes include:

  • Type hint lru_cache as a descriptor to adjust parameters when used as a method
    • This erases all parameters for methods. This is similar to the typeshed hints for the standard library, but actually preservers parameters when not used as a method.
  • Add type-tests in addition to unit-tests

Closes #104.

@codecov
Copy link

codecov bot commented Mar 21, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (ae606a9) 99.25% compared to head (749e428) 99.28%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
+ Coverage   99.25%   99.28%   +0.02%     
==========================================
  Files          20       20              
  Lines        2017     2225     +208     
  Branches      308      368      +60     
==========================================
+ Hits         2002     2209     +207     
  Misses         10       10              
- Partials        5        6       +1     
Impacted Files Coverage Δ
unittests/test_functools.py 96.17% <100.00%> (+0.28%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@maxfischer2781 maxfischer2781 merged commit a6fc497 into master Apr 30, 2023
@maxfischer2781 maxfischer2781 deleted the typing/lru_cache_method branch January 3, 2024 10:56
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.

alru_cache decorator on a class method causes mypy error: Missing positional argument "self"
1 participant