Add Python return type for async functions #1984
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in #1970, uniffi currently doesn't put a return type on generated async functions in Python.
This is my attempt at correcting the function signatures it generates. Because the diff is a bit bad, I'll summarize the changes:
a. If they do, add
async
to the front of the function, add the-> ___
return type, and addawait
to the return statement.b. If they don't, still add
async
to the front of the function andawait
to the return.match meth.return_type()
cases from the body of the function, as it's now being checked outside of the functionThe changes are repeated in
macros.py
andTopLevelFunctionTemplate.py
b.
technically could remain unchanged, but it seemed more correct to make the generated functions match each other.Note that I'm by no means a Python expert, so please let me know if there's a more ergonomic/preferred way to accomplish all this.