Skip to content

Commit a3005a5

Browse files
committed
Automatically treat nested modules as submodules
fixes PyO3#4286
1 parent ee9123a commit a3005a5

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

pyo3-macros-backend/src/module.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ pub fn pymodule_module_impl(
237237
)? {
238238
set_module_attribute(&mut item_mod.attrs, &full_name);
239239
}
240+
item_mod.attrs.push(parse_quote!(#[pyo3(submodule)]));
240241
}
241242
}
242243
Item::ForeignMod(item) => {

tests/test_declarative_module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ mod declarative_module {
115115
}
116116
}
117117

118-
#[pymodule(submodule)]
118+
#[pymodule]
119119
#[pyo3(module = "custom_root")]
120120
mod inner_custom_root {
121121
use super::*;

0 commit comments

Comments
 (0)