New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix IRB deprecation warning on tab-completion #37100
Fix IRB deprecation warning on tab-completion #37100
Conversation
c390406
to
404daa6
Compare
The build errors appear to be unrelated. Something to do with failing to build |
404daa6
to
25fa3f3
Compare
@@ -145,6 +145,10 @@ def inspect | |||
target.inspect | |||
end | |||
|
|||
# Don't give a deprecation warning on methods that IRB may invoke | |||
# during tab-completion. | |||
delegate :hash, :instance_methods, to: :target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered future-proofing this with
delegate *BasicObject.public_instance_methods, to: :target
but that seems too heavy-handed. Would
delegate :hash, *BasicObject.public_instance_methods.grep(/methods/), to: :target
be better?
IRB invokes `#hash` (via a call to `Hash#include?`) and `#instance_methods` on each object in `ObjectSpace.each_object(Module)` when performing tab-completion on chain of method calls. This patch prevents a deprecation warning from being printed when any of those objects are a `ActiveSupport::Deprecation::DeprecatedConstantProxy`. Fixes rails#37097.
25fa3f3
to
5c80059
Compare
Thanks! Let's just keep it to this and see how well this fares in future Ruby versions. I'd rather not add the dynamic delegate just yet. |
Will this be backported to 6-0-stable? |
- Similar fix as rails#37100 which solved the issue only for ruby 2.6. Fix rails#37775
Thanks @kaspth, is there a way we can get this merged to 6-0-stable? |
Backported |
…warning Fix IRB deprecation warning on tab-completion
Thanks so much! |
Same thing as #37100, but [pry also calls `#respond_to?` on the target object](https://github.com/pry/pry/blob/fa97d5c2997ff1cf03cf925df482a7a1d9ca3ea3/lib/pry/input_completer.rb#L194). Fixes #37097 for Pry users.
Can you explain to the non-intelligent people what to do? Do we update rails, downgrade it or update ruby |
@vixalien This fix will be included in Rails 6.0.3, though I'm not sure when that will be released. In the mean time, if you're feeling bold, you can point your Gemfile to the gem "rails", github: "rails/rails", branch: "6-0-stable" |
IRB invokes
#hash
(via a call toHash#include?
) and#instance_methods
on each object inObjectSpace.each_object(Module)
when performing tab-completion on chain of method calls. This patch prevents a deprecation warning from being printed when any of those objects are aActiveSupport::Deprecation::DeprecatedConstantProxy
.Fixes #37097.