Skip to content

Conversation

Tpt
Copy link
Contributor

@Tpt Tpt commented Sep 9, 2025

They have been stable for a few releases now

@Tpt Tpt added the CI-skip-changelog Skip checking changelog entry label Sep 9, 2025
@Tpt Tpt marked this pull request as ready for review September 10, 2025 13:21
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.

Thanks for improving this! A few thoughts.

Comment on lines 88 to 96
# Python::attach(|py| {
# use pyo3::wrap_pymodule;
# use pyo3::types::IntoPyDict;
# use pyo3::ffi::c_str;
# let parent_module = wrap_pymodule!(parent_module)(py);
# let ctx = [("parent_module", parent_module)].into_py_dict(py).unwrap();
#
# py.run(c_str!("assert parent_module.child_module.func() == 'func'"), None, Some(&ctx)).unwrap();
# })
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need to remove the doctest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, added back

```rust,no_run
# mod declarative_module_module_attr_test {
use pyo3::prelude::*;
You can provide the `submodule` argument to `#[pymodule()]` for modules that are not top-level modules in order for them to properly generate the `#[pyclass]` `module` attribute automatically.
Copy link
Member

Choose a reason for hiding this comment

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

I think this probably needs to be moved up into the submodules section (and can have a note saying the inline form will do it automatically).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -3,6 +3,7 @@
You can create a module using `#[pymodule]`:
Copy link
Member

Choose a reason for hiding this comment

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

We should decide if we prefer the inline or use-ing form? I note the readme used the inline form, so we should introduce that first maybe? Or maybe introduce both here, just for functions, and then add more detail below?

Copy link
Contributor Author

@Tpt Tpt Sep 15, 2025

Choose a reason for hiding this comment

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

I have updated the first example to present both ways of exposing a function (each with an inline comment) and kept the dedicated section about inline elements, describing them all

Tpt and others added 2 commits September 15, 2025 09:47
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.

Thanks, agreed I think that this syntax is straight up better than the #[pymodule] functions, and fully supersedes it.

So let's start here and maybe deprecate #[pymodule] functions in a future release (for 0.27 we are now already deprecating #[pyfn]).

@davidhewitt davidhewitt added this pull request to the merge queue Sep 18, 2025
Merged via the queue into PyO3:main with commit 26d5a23 Sep 18, 2025
43 checks passed
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.

2 participants