Cleanup some direct magic method definitions by moreal · Pull Request #7441 · RustPython/RustPython
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>
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>
moreal
changed the title
Cleanup some legacy direct magic method definitions
Cleanup some direct magic method definitions
moreal
marked this pull request as ready for review
youknowone pushed a commit to youknowone/RustPython that referenced this pull request
* Migrate direct __repr__ definitions to Representable trait 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> * Migrate direct __del__ definition to Destructor trait for PySocket 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> * Remove redundant __iter__ pymethods from PyFuture and PyTask 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> * Enable derive guards for __get__/__set__/__delete__ descriptor methods 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> * Enable derive guards for AsMapping/AsSequence slot methods 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> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
youknowone pushed a commit to youknowone/RustPython that referenced this pull request
* Migrate direct __repr__ definitions to Representable trait 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> * Migrate direct __del__ definition to Destructor trait for PySocket 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> * Remove redundant __iter__ pymethods from PyFuture and PyTask 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> * Enable derive guards for __get__/__set__/__delete__ descriptor methods 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> * Enable derive guards for AsMapping/AsSequence slot methods 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> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters