Skip to content

Replace &String -> &str#8136

Merged
youknowone merged 1 commit into
RustPython:mainfrom
ShaharNaveh:ref-module-str
Jun 22, 2026
Merged

Replace &String -> &str#8136
youknowone merged 1 commit into
RustPython:mainfrom
ShaharNaveh:ref-module-str

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Summary by CodeRabbit

  • Refactor
    • Improved internal code structure in module handling logic with streamlined parameter handling and simplified control flow patterns for better maintainability.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 683ab1cb-9069-4881-942f-0b2054e589ba

📥 Commits

Reviewing files that changed from the base of the PR and between eb51444 and c4a746e.

📒 Files selected for processing (1)
  • crates/vm/src/builtins/module.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/vm/src/builtins/module.rs

📝 Walkthrough

Walkthrough

In crates/vm/src/builtins/module.rs, the is_uninitialized_submodule helper's module_name parameter type is changed from Option<&String> to Option<&str>. The call site is updated with .as_deref(), and the function body is rewritten using let … else { return false; } early-return style for fallible attribute lookups.

Changes

Module attribute helper refactor

Layer / File(s) Summary
is_uninitialized_submodule signature, body, and call site
crates/vm/src/builtins/module.rs
Parameter type changed from Option<&String> to Option<&str>; call site updated with .as_deref(); function body rewritten to use let … else { return false; } early-return destructuring for modules/submodule/spec lookups, preserving _initializing resolution via get_attr + try_to_bool + unwrap_or(false).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A &String once roamed through the module's domain,
But &str is lighter — no need for the chain!
With as_deref() the call site aligns,
And let … else neatly unwinds,
The rabbit hops fast down the early-return lane! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 refactoring: replacing &String with &str in the module.rs file, which aligns with the code changes shown in the summary.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youknowone youknowone merged commit 828cf21 into RustPython:main Jun 22, 2026
26 checks passed
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