Repository navigation
Replace untyped return types in PP with concrete types - #3234
Merged
Merged
Conversation
pretty_print, pretty_print_cycle, PP#pp, #pp_object and #pp_hash are called for their side effects, so return void. pretty_print_inspect returns String. PP.pp and PP.singleline_pp return their out argument, or $> (IO) when it is omitted. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
apiology
marked this pull request as ready for review
October 14, 2026 19:55
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Claude: This PR was written by Claude Code on behalf of @apiology.
Problem:
Most return types in
stdlib/pp/0/pp.rbsareuntyped, so values fromPPlose their types:Solution:
Following
lib/pp.rb(v0.6.4):untyped→PP::_PrettyPrint#pretty_print,#pretty_print_cyclevoidPP::ObjectMixin#pretty_print,#pretty_print_cyclevoidPP::PPMethods#pp,#pp_object,#pp_hashvoidPP::ObjectMixin#pretty_print_inspectStringPP.singleline_pp(self, ''.dup)PP.pp,PP.singleline_ppT(theoutargument), orIOwithoutoutout, which defaults to$>voidaccepts any implementation return value, so existingpretty_printdefinitions (e.g. the-> untypedones instdlib/openssl) stay compatible.PP.ppandPP.singleline_ppare split into two overloads, as inMarshal.dump, because a single?T outoverload leavesTunbound whenoutis omitted:Test plan
bundle exec rake validatetest/stdlib/PP_test.rb(also with--enable-frozen-string-literal), with added cases forPP.ppwithoutoutand withwidthbundle exec steep checkbundle exec rubocop test/stdlib/PP_test.rb🤖 Generated with Claude Code
https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb