From d4c503a471cfd202c56fbddd99d5da431a4b7478 Mon Sep 17 00:00:00 2001 From: "St. HeMeow" Date: Fri, 2 Aug 2024 19:52:48 +0100 Subject: [PATCH] Type hint Correction (#8972) * Type hint Correction * add changeset * typecheck --------- Co-authored-by: gradio-pr-bot Co-authored-by: freddyaboulton --- .changeset/four-zebras-worry.md | 5 +++++ gradio/components/radio.py | 4 ++-- gradio/components/upload_button.py | 2 +- test/components/test_radio.py | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/four-zebras-worry.md diff --git a/.changeset/four-zebras-worry.md b/.changeset/four-zebras-worry.md new file mode 100644 index 000000000000..f996f8fa29ae --- /dev/null +++ b/.changeset/four-zebras-worry.md @@ -0,0 +1,5 @@ +--- +"gradio": patch +--- + +feat:Type hint Correction diff --git a/gradio/components/radio.py b/gradio/components/radio.py index 4d0c9b8c36a2..e10f2fd3e15d 100644 --- a/gradio/components/radio.py +++ b/gradio/components/radio.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable, Literal, Sequence from gradio_client.documentation import document @@ -29,7 +29,7 @@ def __init__( | None = None, *, value: str | int | float | Callable | None = None, - type: str = "value", + type: Literal["value", "index"] = "value", label: str | None = None, info: str | None = None, every: Timer | float | None = None, diff --git a/gradio/components/upload_button.py b/gradio/components/upload_button.py index 70d0701e8d40..a75cf757e70b 100644 --- a/gradio/components/upload_button.py +++ b/gradio/components/upload_button.py @@ -49,7 +49,7 @@ def __init__( elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | None = None, - type: Literal["filepath", "bytes"] = "filepath", + type: Literal["filepath", "binary"] = "filepath", file_count: Literal["single", "multiple", "directory"] = "single", file_types: list[str] | None = None, ): diff --git a/test/components/test_radio.py b/test/components/test_radio.py index 1cdeec4b5d8e..17e88d6b30c5 100644 --- a/test/components/test_radio.py +++ b/test/components/test_radio.py @@ -46,7 +46,7 @@ def test_component_functions(self): assert radio.choices == [("a", "a"), ("b", "b"), ("c", "c full")] with pytest.raises(ValueError): - gr.Radio(["a", "b"], type="unknown") + gr.Radio(["a", "b"], type="unknown") # type: ignore def test_in_interface(self): """