Cleanup some direct magic method definitions#7441
Cleanup some direct magic method definitions#7441youknowone merged 5 commits intoRustPython:mainfrom
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 (5)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThis PR refactors special method implementations across multiple modules to use trait-based mechanisms instead of inline implementations. Changes include expanding forbidden slot-method enforcement, migrating Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
Move legacy #[pymethod] __repr__ to impl Representable for: - PySSLContext, PySSLSocket (ssl.rs) - BufferedReader, BufferedWriter, BufferedRandom (_io.rs) Enable __repr__ guard in derive to prevent future direct definitions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bc8dc5d to
5ea0b4d
Compare
Move #[pymethod] __del__ to impl Destructor for PySocket. Preserves ResourceWarning emission and close behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Both types already have impl Iterable, so the direct #[pymethod] __iter__ definitions were duplicates. Enable __iter__/__next__ guards in derive to prevent future direct definitions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All concrete types already use GetDescriptor/SetDescriptor traits. Activate the compile-time guard to prevent future direct definitions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove redundant #[pymethod(name = "__len__")] from PyStr (already provided via AsMapping/AsSequence trait impls). Enable compile-time guards for __len__, __contains__, __getitem__, __setitem__, __delitem__ to prevent future direct definitions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5ea0b4d to
8791e15
Compare
This pull request enables some guards that restricts to implement slot that can be implemented through slot traits, directly.
Summary by CodeRabbit
Bug Fixes
Changes