GeezerVison is showing github.com — Fix unused imports for android by ShaharNaveh · Pull Request #6106 · RustPython/RustPython
Conversation
ShaharNaveh
commented
Aug 23, 2025
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
follow up on #6083
Summary by CodeRabbit
-
New Features
- Improved platform compatibility for Android builds.
-
Bug Fixes
- Resolved Android build issues by disabling an unsupported user-listing capability on Android; other user/group lookup features remain available on supported platforms.
-
Chores
- Added platform-specific guards and minor portability/cleanup changes to ensure consistent behavior across operating systems.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Aug 23, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Walkthrough
Gates Android-specific imports and the getpwall function in vm/src/stdlib/pwd.rs behind #[cfg(not(target_os = "android"))], and replaces an unconditional NonNull import with an explicit std::ptr::NonNull::new(...) usage. Other functions and conversions remain unchanged.
Changes
| Cohort / File(s) |
Summary of Changes |
Android cfg-gating & pointer qualification
vm/src/stdlib/pwd.rs |
- Added #[cfg(not(target_os = "android"))] to PyObjectRef/ToPyObject imports and to getpwall declaration - Removed unconditional NonNull import and qualified usage as std::ptr::NonNull::new(...) inside getpwall loop - No changes to getpwnam, getpwuid, or Passwd conversion logic |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
I hop through cfg fields so neat,
Android’s gate keeps some things discreet.
NonNull now walks a full path each night,
getpwall sleeps where droids take flight. 🐇
Tip
🔌 Remote MCP (Model Context Protocol) integration is now available!
Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.
📜 Recent review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📥 Commits
Reviewing files that changed from the base of the PR and between 26dc2e9 and 9bf6cc3.
📒 Files selected for processing (1)
vm/src/stdlib/pwd.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Check Rust code with rustfmt and clippy
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Ensure compilation on various targets
✨ Finishing Touches
🧪 Generate unit tests
- 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.
❤️ Share
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.
Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitai in a new review comment at the desired location with your query.
- PR comments: Tag
@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
- Add
@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
- Add
@coderabbitai anywhere in the PR title to generate the title automatically.
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
vm/src/stdlib/pwd.rs (1)
106-110: Replace non-existent str::ptr::NonNull with std::ptr::NonNull
The code on line 106 currently references str::ptr::NonNull, which does not exist and will fail to compile on non-Android targets. It must be changed to std::ptr::NonNull. Optionally, you can specify the pointee type (<libc::passwd>) to satisfy Clippy in some toolchains.
• File: vm/src/stdlib/pwd.rs
– Line 106
Proposed minimal fix:
- while let Some(ptr) = str::ptr::NonNull::new(unsafe { libc::getpwent() }) {
+ while let Some(ptr) = std::ptr::NonNull::new(unsafe { libc::getpwent() }) {
Optional clarity for Clippy:
- while let Some(ptr) = std::ptr::NonNull::new(unsafe { libc::getpwent() }) {
+ while let Some(ptr) = std::ptr::NonNull::<libc::passwd>::new(unsafe { libc::getpwent() }) {
🧹 Nitpick comments (1)
vm/src/stdlib/pwd.rs (1)
97-114: API decision: consider a stub for Android to preserve parity
Currently getpwall is unavailable on Android. That’s acceptable; however, consider exporting a stub on Android that raises a Python NotImplementedError to keep the module’s API surface consistent across platforms. This can help avoid runtime attribute checks in callers.
If you want, I can draft a minimal Android-only stub that compiles without reintroducing unused-import warnings.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📥 Commits
Reviewing files that changed from the base of the PR and between e3e0e8a and 26dc2e9.
📒 Files selected for processing (1)
vm/src/stdlib/pwd.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style (cargo fmt to format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust
Files:
🔇 Additional comments (2)
vm/src/stdlib/pwd.rs (2)
7-13: Imports reshuffle looks good
IntoPyException is used in getpwuid, and the other items are required elsewhere in the file. No new lints introduced here.
16-17: Good use of cfg to eliminate Android-only unused imports
Gating PyObjectRef and ToPyObject behind #[cfg(not(target_os = "android"))] aligns with the goal of silencing Android warnings. These are only needed by getpwall, which is also non-Android.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|