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

allow #[pymodule(...)] to accept all relevant #[pyo3(...)] options #4330

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

davidhewitt
Copy link
Member

Loosely a follow-up to #4308, cc @alex

This change makes #[pymodule] consistent with #[pyfunction] and #[pyclass] in that it now accepts all the module-related #[pyo3(...)] options directly in #[pymodule(...)]

e.g. #[pymodule] #[pyo3(name = "foo")] can now be the shorthand #[pymodule(name = "foo")].

While doing this I made a few adjustments to the #[pymodule] macro implementation to make it more consistent with how the others are implemented. I also updated the docs on #[pymodule] at the same time.

@alex
Copy link
Contributor

alex commented Jul 9, 2024

As matter of API style, I like this. Didn't review the impl closely

@@ -4,8 +4,14 @@ error: `submodule` may only be specified once (it is implicitly always specified
4 | mod submod {}
| ^^^

error[E0433]: failed to resolve: use of undeclared crate or module `submod`
--> tests/ui/duplicate_pymodule_submodule.rs:4:6
error[E0425]: cannot find value `_PYO3_DEF` in module `submod`
Copy link
Member Author

Choose a reason for hiding this comment

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

This error looks a bit strange; is the result of the macro failing early with errors and not emitting the complete submodule.

I think changes like #4243 can improve this in future.

@davidhewitt davidhewitt mentioned this pull request Jul 10, 2024
@davidhewitt davidhewitt added this pull request to the merge queue Jul 10, 2024
Merged via the queue into PyO3:main with commit a5a3f3f Jul 10, 2024
39 of 41 checks passed
@davidhewitt davidhewitt deleted the module-options-parse branch July 10, 2024 23:21
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