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.
Description
This PR improves and deduplicates a whole bunch of deprecation warnings around Gradio, following up on #4203, by:
GradioDeprecationWarning
warning class (sinceDeprecationWarning
s aren't visible by default)find_user_stack_level
helper inspired by Pandas' similar helper that allows an user ofwarnings.warn()
to find the first user code stack level (so warnings point at user code, not at Gradio internals)warn_deprecation
helper that uses the above utilitieswarn_style_method_deprecation
for the repeated.style()
warning message from Remove style parameter #4374warn_output_deprecation
for the repeated output warning message from [BIG PR] Gradio blocks & redesigned components #880warn_input_deprecation
for the repeated input warning message from [BIG PR] Gradio blocks & redesigned components #880The end result is that the user gets pinpointed warnings, e.g.
instead of having to hunt around for these around their codebase since a single warning is only shown once by default.
Also, there's less code than before, in total.
🎯 PRs Should Target Issues
This PR does not target an issue, since this was yet another small annoyance I came across while attempting to upgrade Gradio in the stable-diffusion-webui project.
I can create an issue to say that "warnings aren't helpful", if that... helps.