-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Fix #679: allow async class methods as dependencies #681
Conversation
The CI fails because of linting issues (not related to my changes). Should I fix this or do you prefer a separate PR? |
Black is not pinned and indeed it raises issues it wasn't before
Le mar. 5 nov. 2019 à 9:11 AM, François Voron <notifications@github.com> a
écrit :
… The CI fails because of linting issues (not related to my changes). Should
I fix this or do you prefer a separate PR?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#681?email_source=notifications&email_token=AAINSPWM4U5JTDHO4SUCA2LQSETEFA5CNFSM4JI674J2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDB6VGY#issuecomment-549710491>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAINSPUMXYAZO6GWAXNDOCDQSETEFANCNFSM4JI674JQ>
.
|
Yeah, they fixed something regarding function parameters/trailing commas. Should be quite straightforward to fix, but maybe it should live in another PR. I'll do that quickly. EDIT: See #682. |
@tiangolo what's about merging it? |
8d97025
to
bbd736f
Compare
Codecov Report
@@ Coverage Diff @@
## master #681 +/- ##
======================================
Coverage 100% 100%
======================================
Files 271 276 +5
Lines 7011 7871 +860
======================================
+ Hits 7011 7871 +860
Continue to review full report at Codecov.
|
Rebased the branch with fixed linting to have the pipeline checked 👍 |
Great, thank you @frankie567 ! Thanks for implementing it, and adding extended tests. 🤓 🚀 🍰 🎉 And thanks everyone for the discussion. |
This is the fix for issue #679: allow to use async class methods as dependencies.
Before, such methods were not correctly detected as coroutine and thus were not awaited but rather sent to
run_in_threadpool
. We ended up then injecting the coroutine instead of its result.I've used
inspect.isroutine
, instead of doinginspect.isfunction(call) or inspect.ismethod(call)
. It seems to fulfill our need while saving us a check.I also took this opportunity to add some unit tests to verify the different use cases regarding class dependencies (callable, async callable, sync methods and async methods).
It could also be interesting to mention those possibilities in the Classes as Dependencies section of the documentation. What do you think?