-
Notifications
You must be signed in to change notification settings - Fork 58
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
Use ParamSpec for wrapped signatures #508
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #508 +/- ##
==========================================
+ Coverage 96.88% 96.92% +0.03%
==========================================
Files 12 12
Lines 770 780 +10
Branches 91 93 +2
==========================================
+ Hits 746 756 +10
Misses 22 22
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good step forward, thanks!
I'll review this soonish and see if I can get the last issues resolved. |
@Dreamsorcerer As someone who would like to see these features get added myself, I also made my own version before seeing this Pull Request that injects _Coro = Coroutine[Any, Any, _R]
_CB = Callable[_P, _Coro[_R]]
_CBOM = Union[_CB[_P, _R], _CB[Concatenate[Self, _P], _R]]
_CBP = Union[_CBOM[_P, _R], "partial[_Coro[_R]]", "partialmethod[_Coro[_R]]"] I call For some reason it didn't branch to your pull request specifically but I hope my additions to your pull request will at least excite you. I do give you credit though for coming up with this solution to begin with. |
Fixes #504.
There are still a couple of issues with this.
partial()
use will cause new type errors. We can either wait until partial() is properly supported by typedshed/mypy (functools.partial should use PEP612 ParamSpec (depends on #8708) python/typeshed#8703 / functools.partial support python/mypy#1484), or we could expose aTypeAlias
of_LRUCacheWrapper
so it can be used in type annotations.There also seems to be an issue with pypy, possibly a bug in pypy, but needs further investigation.