-
Notifications
You must be signed in to change notification settings - Fork 765
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
PyO3 v0.21 beta pyfunction annotation coverage #3989
Comments
#1726 may be relevant as a past similar issue |
My specific hypothesis in this case is that the error code paths are never covered. |
I guess this is probably true, though it's tricky to know what we can do about it. We might be able to modify the generated code be smarter to make the compiler not care about the error paths, if that is indeed the case. Would you be willing to use |
I think adding |
Aha that red block is the new code we added to support declarative modules, cc @Tpt I think what we can probably do is refactor that code into traits so that we don't need to emit a function directly in that position. I'm happy to have a go at this but might not be until the weekend or so, so if someone is happy to try sooner please do! |
FYI, I think there's two other situations in which we aren't getting coverage -- one on pyclass and one on import_exception. I've poked @reaperhulk to see if we can get clean screenshots on those as well. |
It is very likely the same code for supporting those types. 👍 |
It looks like for Is the goal of moving them to an |
The tricky thing here is that traits can be implemented by stucts and enum but not function and modules so it won't work with |
Agreed that the functions and modules can't directly implement traits, but their helper I think rather than adding Maybe something like this: #[doc(hidden)]
mod generate_key 1 {
pub (crate) struct MakeDef;
pub const DEF: ::pyo3::impl_::pymethods::PyMethodDef = MakeDef::DEF;
}
// change this bit to a trait implementation?
impl ::pyo3::impl::pymodule::PyAddToModule for generate_key::MakeDef {
const DEF: ::pyo3::impl_::pymethods::PyMethodDef = :: pyo3::impl_::pymethods::PyMethodDef::noargs (...);
} I think that code isn't exactly right, but hopefully it conveys the idea. Really all we need to do is get a constant exposed, and if the namespaces look the same, (e.g. |
Alex attempted implementing some of this in main...alex:pyo3:add-to-module-auto but pyclass/import_exception coverage did not improve in our tests. 😢 |
Yes! The trick is to figure out the proper bounds for the trait implementation and, sadly, I am not sure to have figured them out, mostly because of the rule that prevents more than one blanket implementation |
Well, we also need to figure out why it is that |
Would you perhaps be willing to expand the |
Yup, Paul's doing so now.
…On Fri, Mar 29, 2024 at 7:56 AM David Hewitt ***@***.***> wrote:
From @alex in #4009
All invocations of pyo3::import_exception
Exactly one pyclass
One other bizzaro line (that's probably not related to pyo3)
Would you perhaps be willing to expand the pyclass and see what looks to be related there? I'll take a look at import_exception now, hopefully that's obvious...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
For I wonder if a solution would be to have |
The answer on pyclass was that it was a |
Well, I've got good news and I've got news. The good news is that we've managed to get to 100% coverage: pyca/cryptography#10671 The news is that this was done by dropping some of the migrations to bound APIs (compare with @reaperhulk's PR pyca/cryptography#10633). My preference at this point would be to get an 0.21.1 release out with the coverage improvements we have, and then we'll do follow up PRs based on far more specific issues as we burn down the usage of the |
I'm thinking similarly re 0.21.1. I'd like to try to add |
Works for me.
…On Sat, Mar 30, 2024 at 9:42 AM David Hewitt ***@***.***> wrote:
I'm thinking similarly re 0.21.1.
I'd like to try to add import_exception_bound! which doesn't emit the GIL Refs implementations, as I think that'll be helpful for you. In my head I push that tonight and then we get 0.21.1 out over the rest of the Easter weekend.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
Is there anything else to get in for 0.21.1? |
Not any more :) |
Going to declare this resolved for now, with an expectation that follow up tickets may be filed with more specific coverage issues. |
Sure thing. Thanks for the reporting and help identifying / fixing! |
In PyO3 v0.21.0-beta.0 we (pyca/cryptography) are seeing an issue where some
#[pyo3::prelude::pyfunction]
annotations on functions are marked as uncovered lines. This appears to occur only on functions where the function cannot error.An example function:
https://github.com/pyca/cryptography/blob/e9954a0a31db22201b96d62535f51a5f0316e218/src/rust/src/backend/x25519.rs#L19-L24
I'm sure I can build a minimal reproducer if necessary, but if this is sufficient information then great 😄
The text was updated successfully, but these errors were encountered: