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

remove type_is_pymodule #3594

Merged
merged 2 commits into from Nov 24, 2023
Merged

Conversation

davidhewitt
Copy link
Member

Follow-up to #3587

This removes the type_is_pymodule check. I had to propagate the span of the first argument through the macro code to get the compiler error to hint at the right place, overall I think this is a nice cleanup.

@davidhewitt davidhewitt added the CI-skip-changelog Skip checking changelog entry label Nov 22, 2023
@@ -3,10 +3,10 @@ use pyo3::prelude::*;
#[pymodule]
fn module(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
#[pyfn(m, pass_module)]
fn fail(string: &str, module: &PyModule) -> PyResult<&str> {
fn fail<'py>(string: &str, module: &'py PyModule) -> PyResult<&'py str> {
Copy link
Member Author

Choose a reason for hiding this comment

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

The original check was masking an ambiguous lifetime error; I needed to add lifetime hints to avoid having this error also included in the trybuild output.

@davidhewitt
Copy link
Member Author

cc @wyfo

@davidhewitt
Copy link
Member Author

Ah I'll push a test for the empty arguments branch in the morning.

@wyfo
Copy link
Contributor

wyfo commented Nov 22, 2023

I had to propagate the span of the first argument through the macro code to get the compiler error to hint at the right place

Good point, but now it's my turn to tell you that I think you should do the same for FnClass/FnNewClass 😃

@wyfo
Copy link
Contributor

wyfo commented Nov 22, 2023

Thanks to the structure of your modification, I've realized that I forgot to update the line 380 in method.rs. Could you do that in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this test into invalid_pyfunctions.rs

#[allow(clippy::useless_conversion)]
::std::convert::Into::into(_pyo3::types::PyType::from_type_ptr(py, _slf as *mut _pyo3::ffi::PyTypeObject)),
::std::convert::Into::into(_pyo3::types::PyType::from_type_ptr(#py, #slf.cast())),
}
}
FnType::FnModule(span) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should _slf also be declared as a syn::Indent like above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Initially I did that but got a hygiene error and backed out. Probably that needs investigating but if the test suite compiles I'm not super concerned.

@wyfo
Copy link
Contributor

wyfo commented Nov 24, 2023

I've no Approve button, so I will just write 👍

@davidhewitt
Copy link
Member Author

👍 thanks for the review!

I've no Approve button, so I will just write 👍

If you're reviewing regularly we should look at getting that set up 👀

@davidhewitt davidhewitt added this pull request to the merge queue Nov 24, 2023
Merged via the queue into PyO3:main with commit 31b871a Nov 24, 2023
36 checks passed
@davidhewitt davidhewitt deleted the remove_type_is_pymodule branch November 24, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants