lostisland / faraday

Simple, but flexible HTTP client library, with support for multiple backends.
https://lostisland.github.io/faraday
MIT License
5.72k stars 972 forks source link

Disable upgrade warnings by default #1410

Closed iMacTia closed 2 years ago

iMacTia commented 2 years ago

This seems to be an issue again on the jump from v1 to v2. I'm getting a bunch of these:

WARNING: `Faraday::Connection#basic_auth` is deprecated; it will be removed in version 2.0.
While initializing your connection, use `#request(:basic_auth, ...)` instead.
See https://lostisland.github.io/faraday/middleware/authentication for more usage info.
WARNING: `Faraday::Connection#basic_auth` is deprecated; it will be removed in version 2.0.
[...]

Did you move away from the FARADAY_DEPRECATE idea? To be clear, I don't even directly depend on faraday-- it comes through another dependency.

Originally posted by @kyrofa in https://github.com/lostisland/faraday/issues/1089#issuecomment-1086227010

hyuraku commented 2 years ago

@iMacTia We would like to add Faraday#DeprecatedClass to Faraday ver1.xx like https://github.com/lostisland/faraday/commit/6e746fceefe0d1f75535b40a62d846a6a95bf85f , How about?

iMacTia commented 2 years ago

@hyuraku yep that would work!

hyuraku commented 2 years ago

@iMacTia I could not solve the warning by adding Faraday#DeprecatedClass because the class could not hide custom warning message. I suggest adding the module in lib/faraday/warning.rb below to hide the warning message; how about?

module CustomWarningFilter
  def warn(message)
    deprecate = ENV['FARADAY_DEPRECATE'].to_s.downcase
    if !(deprecate == '1' || deprecate == 'warn')
      super
    end
  end
end
Warning.extend CustomWarningFilter
iMacTia commented 2 years ago

Oh right, Faraday#DeprecatedClass deprecates an entire class, but I thought you wanted to use Faraday::Deprecate#deprecate from that PR. That should allow you do deprecate individual methods with a similar configurable behaviour.

I'd rather not extend or mess with public standard classes like Warning as that could have unexpected repercussions on projects and affects things outside of Faraday's control.

iMacTia commented 2 years ago

This was fixed in #1438 🎉 Thank you @hyuraku 🙏