#[pymodule] submodule support and implicit module_name inheritance by youknowone · Pull Request #7203 · RustPython/RustPython
Caution
Review failed
The pull request is closed.
ℹ️ Recent review info
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
crates/derive-impl/src/pymodule.rs
📝 Walkthrough
Walkthrough
Detects nested #[pymodule] items and emits per-item submodule initialization code injected into the parent module's init flow (preserving each item's cfg attributes). Also computes has_module/module_name for StructSequenceItem, auto-filling nested module meta with the current module name when absent.
Changes
| Cohort / File(s) | Summary |
|---|---|
Pymodule nested detection & struct-sequence handling crates/derive-impl/src/pymodule.rs |
Detect nested #[pymodule] items and collect submodule_inits; inject generated submodule init blocks into __init_attributes (module creation, init, exec, binding) while honoring per-item #[cfg]. Update StructSequenceItem to compute has_module/module_name from meta or default to current module. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- #[pymodule] submodule support and implicit module_name inheritance #7203 — Modifies the same
crates/derive-impl/src/pymodule.rsarea to add nested#[pymodule]submodule init injection and related module-name handling. - Support #[cfg] in pymodule with #6975 — Touches
pymoduleimplementation incrates/derive-impl/src/pymodule.rs, adding related handling for module args and#[cfg]on items.
Poem
🐰 I found a tunnel in the code so deep,
Little submodules woke from their sleep,
Init hops in, flags kept in sight,
Defaults filled softly in the night,
A rabbit cheers for nested delight 🥕
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title accurately describes the main changes: adding submodule support for #[pymodule] and implementing implicit module_name inheritance, which matches the AI-generated summary of changes. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
- 📝 Generate docstrings (stacked PR)
- 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.