Implement missing slots for NoneType#7437
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds Comparable and Hashable implementations for the PyNone singleton (including a fixed NONE_HASH); removes many Python-level dunder wrapper method signatures from slot-related traits; removes explicit repr wrappers for struct sequences; and expands tests to assert None's comparison behaviors and hash value. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/types.py dependencies:
dependent tests: (52 tests)
Legend:
|
|
As a memo, it seems 765133c commit added pymethods to |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/vm/src/builtins/singletons.rs (1)
53-54: Consider addingIMMUTABLETYPEflag for consistency.The
ComparableandHashableadditions are correct. However, note thatPyNotImplemented(line 122) includesflags(IMMUTABLETYPE)whilePyNonedoes not. Both are singletons with similar semantics, so you may want to add this flag here for consistency.Optional consistency fix
-#[pyclass(with(Constructor, AsNumber, Comparable, Hashable, Representable))] +#[pyclass(with(Constructor, AsNumber, Comparable, Hashable, Representable), flags(IMMUTABLETYPE))] impl PyNone {}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/vm/src/builtins/singletons.rs` around lines 53 - 54, Add the IMMUTABLETYPE flag to PyNone's pyclass attribute to match PyNotImplemented: update the PyNone declaration (#[pyclass(with(Constructor, AsNumber, Comparable, Hashable, Representable))] impl PyNone {}) to include flags(IMMUTABLETYPE) so the singleton is marked immutable like PyNotImplemented.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/vm/src/builtins/singletons.rs`:
- Around line 53-54: Add the IMMUTABLETYPE flag to PyNone's pyclass attribute to
match PyNotImplemented: update the PyNone declaration
(#[pyclass(with(Constructor, AsNumber, Comparable, Hashable, Representable))]
impl PyNone {}) to include flags(IMMUTABLETYPE) so the singleton is marked
immutable like PyNotImplemented.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: f03bde30-5a15-45cc-a93f-89952ea2194b
📒 Files selected for processing (1)
crates/vm/src/builtins/singletons.rs
youknowone
left a comment
There was a problem hiding this comment.
Looks good, and thank you for catching legacy python magic methods.
There must be a bunch more of those unnecessary magic methods. Could you investigate more about other methods too?
Co-authored-by: Jeong, YunWon <[email protected]>
Okay, I will do in the next pull request. |
This pull request does two things. First, as the title, it implements missing slots (e.g.,
__eq__) forNoneType.And it lets slot traits (e.g.,
Comparable) implement only the slot (wrapper_descriptor), not the method. This task was ongoing, and this commit may complete it (#6486).It will remove
NoneTypefrom whats_left.Summary by CodeRabbit
Improvements
Behavior Changes
Tests