General code nits#8041
Conversation
|
Need the big picture first? Review this PR in Change Stack to see what changed before going file by file. 📝 WalkthroughWalkthroughThis PR systematically refactors error message handling and code patterns across eleven stdlib modules to reduce string allocations and improve code style. The largest change updates the ChangesError handling and code pattern refactoring
🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/vm/src/stdlib/_io.rs`:
- Around line 366-367: Update the UnsupportedOperation error messages to match
CPython exactly by adding the trailing period to the strings "File or stream is
not readable" and "File or stream is not writable" wherever they are raised in
crates/vm/src/stdlib/_io.rs (the UnsupportedOperation paths around the locations
using those exact texts). Search for the two literal strings and modify them to
"File or stream is not readable." and "File or stream is not writable." so
functions/branches that construct or raise UnsupportedOperation use the exact
CPython wording.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: ab7e2efc-03e4-4d74-ac52-98c55b448dac
📒 Files selected for processing (11)
crates/stdlib/src/binascii.rscrates/stdlib/src/unicodedata.rscrates/vm/src/builtins/dict.rscrates/vm/src/builtins/list.rscrates/vm/src/stdlib/_collections.rscrates/vm/src/stdlib/_io.rscrates/vm/src/stdlib/_thread.rscrates/vm/src/stdlib/_weakref.rscrates/vm/src/stdlib/builtins.rscrates/vm/src/stdlib/itertools.rscrates/vm/src/stdlib/typevar.rs
| "File or stream is not readable", | ||
| vm, |
There was a problem hiding this comment.
Preserve exact CPython-readable/writable error text (trailing period).
Line 366 and Lines 5588/5646/5681 use messages without the trailing . in some readable/writable UnsupportedOperation paths. That diverges from CPython’s _pyio text ("File or stream is not readable." / "File or stream is not writable.") and can break strict behavior parity tests.
Suggested patch
- Err(new_unsupported_operation(
- "File or stream is not readable",
- vm,
- ))
+ Err(new_unsupported_operation(
+ "File or stream is not readable.",
+ vm,
+ ))- return Err(new_unsupported_operation(
- "File or stream is not readable",
- vm,
- ));
+ return Err(new_unsupported_operation(
+ "File or stream is not readable.",
+ vm,
+ ));- return Err(new_unsupported_operation(
- "File or stream is not readable",
- vm,
- ));
+ return Err(new_unsupported_operation(
+ "File or stream is not readable.",
+ vm,
+ ));- return Err(new_unsupported_operation(
- "File or stream is not writable",
- vm,
- ));
+ return Err(new_unsupported_operation(
+ "File or stream is not writable.",
+ vm,
+ ));Also applies to: 5587-5590, 5645-5648, 5680-5683
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/vm/src/stdlib/_io.rs` around lines 366 - 367, Update the
UnsupportedOperation error messages to match CPython exactly by adding the
trailing period to the strings "File or stream is not readable" and "File or
stream is not writable" wherever they are raised in crates/vm/src/stdlib/_io.rs
(the UnsupportedOperation paths around the locations using those exact texts).
Search for the two literal strings and modify them to "File or stream is not
readable." and "File or stream is not writable." so functions/branches that
construct or raise UnsupportedOperation use the exact CPython wording.
Summary
Summary by CodeRabbit
Refactor
Optimization