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

feat: add #[pyo3(from_item_all)] for FromPyObject #3120

Merged
merged 8 commits into from
May 4, 2023

Conversation

BlueGlassBlock
Copy link
Contributor

@BlueGlassBlock BlueGlassBlock commented Apr 25, 2023

This PR addresses #3112 by implementing #[pyo3(item_all)] #[pyo3(from_item_all)].

@adamreichold
Copy link
Member

I think UI tests exercising the error paths would be good to have here.

@BlueGlassBlock
Copy link
Contributor Author

I think UI tests exercising the error paths would be good to have here.

I've noticed that, and I'll figure out how to fix the tests and improve coverage today (that's why I marked this as a draft⁠) (⁠^⁠^⁠)

@davidhewitt
Copy link
Member

It looks like you may have run the UI tests with nightly Rust? Quite a few spans have changed. Suggest rebuilding with stable.

Overall I'm happy for this functionality although I'm unsure about the name item_all. I understand why you chose it though it's not immediately intuitive to me as a reader what it means.

I wonder if something like all_from_items or from_item_all are any clearer? I don't love those either so happy for further suggestions!

@BlueGlassBlock
Copy link
Contributor Author

I personally perfer from_item_all, since that's similar to get_all and set_all which we already have.

I'll update the PR again once I can continue to work on it.

@BlueGlassBlock BlueGlassBlock changed the title feat: add #[pyo3(item_all)] for FromPyObject feat: add #[pyo3(from_item_all)] for FromPyObject Apr 26, 2023
@BlueGlassBlock
Copy link
Contributor Author

It seemed that I forgot some paths in the UI tests. I'll address them soon.

I'm uncertain about the name too. from_items or something like that seems okay to me.

I'm thinking about the divergence in behavior from get_all and set_all, which don't allow specifying the name with get, name = ..., so that seems inconsistent. However, I think allowing specifying args passed to get_item is still useful. Maybe I could separate that to an extra proposal along with changes to get_all and set_all?

@davidhewitt
Copy link
Member

I'm thinking about the divergence in behavior from get_all and set_all, which don't allow specifying the name with get, name = ..., so that seems inconsistent.

This is a good point and something we overlooked when originally implementing get_all and set_all, it would be nice to allow them to accept #[pyo3(name = ...)] on individual fields.

@BlueGlassBlock BlueGlassBlock marked this pull request as ready for review April 27, 2023 05:32
@BlueGlassBlock
Copy link
Contributor Author

Ugh. I didn't manage to make coverage rate pass codecov's check. Are declarative macro invocations blocking llvm-cov to pick them up?

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me, the implementation is comprehensive. For some reason the coverage isn't reporting the error cases from the UI tests, but I see them here, and that normally works, so I think we are good to merge this. Thanks!

bors r+

@bors
Copy link
Contributor

bors bot commented May 4, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 6356acb into PyO3:main May 4, 2023
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.

3 participants