mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-12 12:40:29 +08:00
Fix Wrong Deprecation Warning message for type/plot parameter (#4709)
* Add code * CHANGELOG * Fix * Add to changelog
This commit is contained in:
parent
1650e1d383
commit
2baf33c33f
@ -21,6 +21,8 @@
|
||||
- Fix double upload bug that caused lag in file uploads by [@aliabid94](https://github.com/aliabid94) in [PR 4661](https://github.com/gradio-app/gradio/pull/4661)
|
||||
- `Progress` component now appears even when no `iterable` is specified in `tqdm` constructor by [@itrushkin](https://github.com/itrushkin) in [PR 4475](https://github.com/gradio-app/gradio/pull/4475)
|
||||
- Deprecation warnings now point at the user code using those deprecated features, instead of Gradio internals, by (https://github.com/akx) in [PR 4694](https://github.com/gradio-app/gradio/pull/4694)
|
||||
- The `plot` parameter deprecation warnings should now only be emitted for `Image` components by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 4709](https://github.com/gradio-app/gradio/pull/4709)
|
||||
- Removed uncessessary `type` deprecation warning by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 4709](https://github.com/gradio-app/gradio/pull/4709)
|
||||
- Ensure Audio autoplays works when `autoplay=True` and the video source is dynamically updated [@pngwn](https://github.com/pngwn) in [PR 4705](https://github.com/gradio-app/gradio/pull/4705)
|
||||
|
||||
|
||||
|
@ -11,6 +11,10 @@ class GradioDeprecationWarning(UserWarning):
|
||||
pass
|
||||
|
||||
|
||||
class GradioUnusedKwargWarning(UserWarning):
|
||||
pass
|
||||
|
||||
|
||||
def simple_deprecated_notice(term: str) -> str:
|
||||
return f"`{term}` parameter is deprecated, and it has no effect"
|
||||
|
||||
@ -38,7 +42,6 @@ DEPRECATION_MESSAGE = {
|
||||
"width": use_in_launch("width"),
|
||||
"height": use_in_launch("height"),
|
||||
"plot": "The 'plot' parameter has been deprecated. Use the new Plot component instead",
|
||||
"type": "The 'type' parameter has been deprecated. Use the Number component instead.",
|
||||
}
|
||||
|
||||
|
||||
@ -50,13 +53,15 @@ def check_deprecated_parameters(
|
||||
|
||||
for key, value in DEPRECATION_MESSAGE.items():
|
||||
if key in kwargs:
|
||||
if key == "plot" and cls != "Image":
|
||||
continue
|
||||
kwargs.pop(key)
|
||||
warnings.warn(value, GradioDeprecationWarning, stacklevel=stacklevel)
|
||||
|
||||
if kwargs:
|
||||
warnings.warn(
|
||||
f"You have unused kwarg parameters in {cls}, please remove them: {kwargs}",
|
||||
GradioDeprecationWarning,
|
||||
GradioUnusedKwargWarning,
|
||||
stacklevel=stacklevel,
|
||||
)
|
||||
|
||||
|
@ -26,6 +26,10 @@ from scipy.io import wavfile
|
||||
|
||||
import gradio as gr
|
||||
from gradio import processing_utils, utils
|
||||
from gradio.deprecation import (
|
||||
GradioDeprecationWarning,
|
||||
GradioUnusedKwargWarning,
|
||||
)
|
||||
|
||||
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
||||
|
||||
@ -2891,3 +2895,16 @@ class TestTempFileManagement:
|
||||
|
||||
f = temp_file_manager.download_temp_copy_if_needed(url2)
|
||||
assert len(temp_file_manager.temp_files) == 2
|
||||
|
||||
|
||||
def test_type_arg_deperecation_warning():
|
||||
with pytest.warns(GradioUnusedKwargWarning):
|
||||
gr.Video(type="filepath")
|
||||
|
||||
|
||||
def test_plot_arg_deprecation_warning():
|
||||
with pytest.warns(GradioDeprecationWarning):
|
||||
gr.Image(plot=True)
|
||||
|
||||
with pytest.warns(GradioUnusedKwargWarning):
|
||||
gr.File(plot=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user