Repository: gradio-app/gradio

Issue:
Throw warning if using `gr.inputs.*` or `gr.outputs.*`
I think we used to have a deprecation warning, not sure where it went


Discussion:

Resolving patch:
diff --git a/gradio/components.py b/gradio/components.py
--- a/gradio/components.py
+++ b/gradio/components.py
@@ -1448,7 +1448,6 @@ def format_image(
             if self.type == "file":
                 warnings.warn(
                     "The 'file' type has been deprecated. Set parameter 'type' to 'filepath' instead.",
-                    DeprecationWarning,
                 )
                 return file_obj
             else:
@@ -1996,7 +1995,6 @@ def preprocess(self, x: Dict[str, str] | None) -> Tuple[int, np.array] | str | N
         if self.type == "file":
             warnings.warn(
                 "The 'file' type has been deprecated. Set parameter 'type' to 'filepath' instead.",
-                DeprecationWarning,
             )
             return file_obj
         elif self.type == "filepath":
@@ -2018,7 +2016,6 @@ def serialize(self, x, called_directly):
         elif self.type == "file":
             warnings.warn(
                 "The 'file' type has been deprecated. Set parameter 'type' to 'filepath' instead.",
-                DeprecationWarning,
             )
             name = x.name
         elif self.type == "numpy":
@@ -3177,7 +3174,6 @@ def __init__(
         if color_map is not None:
             warnings.warn(
                 "The 'color_map' parameter has been moved from the constructor to `HighlightedText.style()` ",
-                DeprecationWarning,
             )
         self.show_legend = show_legend
         self.combine_adjacent = combine_adjacent
@@ -3546,7 +3542,6 @@ def __init__(
         """
         warnings.warn(
             "The Carousel component is partially deprecated. It may not behave as expected.",
-            DeprecationWarning,
         )
         if not isinstance(components, list):
             components = [components]
@@ -3659,7 +3654,6 @@ def __init__(
         if color_map is not None:
             warnings.warn(
                 "The 'color_map' parameter has been moved from the constructor to `Chatbot.style()` ",
-                DeprecationWarning,
             )
 
         self.value = self.postprocess(value)
diff --git a/gradio/inputs.py b/gradio/inputs.py
--- a/gradio/inputs.py
+++ b/gradio/inputs.py
@@ -25,7 +25,6 @@ def __init__(
     ):
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(
             value=default,
@@ -58,7 +57,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(value=default, label=label, optional=optional)
 
@@ -89,7 +87,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components",
-            DeprecationWarning,
         )
 
         super().__init__(
@@ -122,7 +119,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(value=default, label=label, optional=optional)
 
@@ -151,7 +147,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(
             value=default,
@@ -186,7 +181,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(
             choices=choices,
@@ -221,7 +215,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(
             choices=choices,
@@ -262,7 +255,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(
             shape=shape,
@@ -299,7 +291,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(format=type, source=source, label=label, optional=optional)
 
@@ -326,7 +317,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(source=source, type=type, label=label, optional=optional)
 
@@ -355,7 +345,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(
             file_count=file_count,
@@ -398,7 +387,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(
             value=default,
@@ -435,7 +423,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(x=x, y=y, label=label, optional=optional)
 
@@ -459,7 +446,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.inputs is deprecated, and will not be supported in the future, please import this component as gr.Variable from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(value=default, label=label)
 
@@ -482,6 +468,5 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(label=label, optional=optional)
diff --git a/gradio/outputs.py b/gradio/outputs.py
--- a/gradio/outputs.py
+++ b/gradio/outputs.py
@@ -20,7 +20,6 @@ def __init__(
     ):
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(label=label, type=type)
 
@@ -42,7 +41,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         if plot:
             type = "plot"
@@ -63,7 +61,6 @@ def __init__(self, type: Optional[str] = None, label: Optional[str] = None):
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(format=type, label=label)
 
@@ -82,7 +79,6 @@ def __init__(self, type: str = "auto", label: Optional[str] = None):
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(type=type, label=label)
 
@@ -100,7 +96,6 @@ def __init__(self, label: Optional[str] = None):
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(label=label)
 
@@ -131,7 +126,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(
             headers=headers,
@@ -160,7 +154,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(x=x, y=y, label=label)
 
@@ -178,7 +171,6 @@ def __init__(self, label: Optional[str] = None):
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(label=label)
 
@@ -203,7 +195,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(num_top_classes=num_top_classes, type=type, label=label)
 
@@ -247,7 +238,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(color_map=color_map, label=label, show_legend=show_legend)
 
@@ -265,7 +255,6 @@ def __init__(self, label: Optional[str] = None):
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(label=label)
 
@@ -301,7 +290,6 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(components=components, label=label)
 
@@ -319,7 +307,6 @@ def __init__(self, label: Optional[str] = None):
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(label=label)
 
@@ -342,6 +329,5 @@ def __init__(
         """
         warnings.warn(
             "Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
-            DeprecationWarning,
         )
         super().__init__(clear_color=clear_color, label=label)


Test patch:
diff --git a/test/test_components.py b/test/test_components.py
--- a/test/test_components.py
+++ b/test/test_components.py
@@ -9,6 +9,7 @@
 import numpy as np
 import pandas as pd
 import PIL
+import pytest
 
 import gradio as gr
 from gradio import media_data
@@ -30,6 +31,14 @@ def test_component_functions(self):
         assert isinstance(gr.components.component("text"), gr.templates.Text)
 
 
+def test_raise_warnings():
+    for c_type, component in zip(
+        ["inputs", "outputs"], [gr.inputs.Textbox, gr.outputs.Label]
+    ):
+        with pytest.warns(UserWarning, match=f"Usage of gradio.{c_type}"):
+            component()
+
+
 class TestTextbox(unittest.TestCase):
     def test_component_functions(self):
         """
@@ -803,7 +812,7 @@ def test_component_functions(self):
         x_wav["is_example"] = True
         x_wav["crop_min"], x_wav["crop_max"] = 1, 4
         self.assertIsNotNone(audio_input.preprocess(x_wav))
-        with self.assertWarns(DeprecationWarning):
+        with self.assertWarns(UserWarning):
             audio_input = gr.Audio(type="file")
             audio_input.preprocess(x_wav)
             with open("test/test_files/audio_sample.wav") as f: