Allow other Result types in #[pyfunction] - #1118
Conversation
kngwyu
left a comment
There was a problem hiding this comment.
Thanks!
I have some minor concerns but it looks that it's nicely fixed 👍
davidhewitt
left a comment
There was a problem hiding this comment.
Thanks! Looks like this was even easier than expected 😄
As for the guide: maybe in this section for now? https://pyo3.rs/v0.11.1/conversions.html#returning-rust-values-to-python
I plan to make a bunch of PRs to improve the guide soon anyway, so as long as this functionality is mentioned in the guide I'll probably move it around if necessary ;)
|
Great, I've made all the suggested fixes now, including mentioning this in the docs. |
|
Thanks, LGTM! Regarding the UI test - I don't think we'll easily improve the error message (that's pretty much part of the compiler), so I'm just going to merge for now and maybe we can improve this later. |
|
Thanks! I'm glad I could contribute to PyO3. Cheers :) |
Thank you for contributing to pyo3!
Please consider adding the following to your pull request:
Be aware the CI pipeline will check your pull request for the following:
cargo testormake testif you need to test examples)make clippy)cargo fmt)black . --check. You can install black withpip install black)tox; you can do run it usingmake test_py.You can run a similar set of checks as the CI pipeline using
make test.I've implemented #1106, see that issue for a description. It was quite simple but I haven't touched this codebase before so please let me know if anything can be improved.
I included a couple tests, one where it works correctly, and another where it fails to compile because
from From<MyErr> for PyErrisn't implemented. What I would like to know before this is merged:tests/ui/invalid_result_conversion.stderrfor the current error message.