-
Notifications
You must be signed in to change notification settings - Fork 34
Preserve and utilize Warning
categories
#86
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
base: main
Are you sure you want to change the base?
Preserve and utilize Warning
categories
#86
Conversation
I have signed the CLA! |
Thanks for your contribution! We should definitely preserve and pass the But we don't need |
It's definitely possible! It would be a pretty straightforward change, and it would feel much more elegant to me. But it would also be a breaking change. At the moment, since Deprecation Toolkit nullifies a warning's category, it effectively enables the |
So the thing I'm seeing is that removing the explicit setting of Testing with RSpec, I also don't see any regression regarding Also worth noting that Ruby still sends the warning to Ruby script that shows warnings are sent even if the category is not enabledmodule WarningExt
def warn(message, category: nil)
super "#{"[#{category.upcase}] " if category}#{message}"
end
end
Warning.extend(WarningExt)
p deprecated: Warning[:deprecated], experimental: Warning[:experimental]
warn "foo"
warn "deprecated", category: :deprecated
warn "experimental", category: :experimental
warn "bar", category: :bar rescue p $! outputs when called with
If we enable warnings with Taking a step back:
1 feels like we should respect the In general, I wouldn't be in favor of configuring things "behind the back" of the application authors (hence why I asked about this) but given that in test/development, using deprecation toolkit, is truly the best time to enable deprecation warnings and track them in order to take care of them some time before the deprecated behavior is removed, I feel like it's fair to enable them. So by combining those two, maybe what we want is to check if the warning is of a category that's enabled, and also enable |
Currently Deprecation Toolkit does not utilize
Warning
's:deprecated
category, and in fact it nullifies any category that is set when callingsuper
. This change will preserve the category that is passed toWarning.warn
; it will automatically enable the:deprecated
category, which the user can disable or restore with a new config option; and it will treat any warning with the:deprecated
category as a deprecation, if the category is enabled.