Type hint Correction (#8972)

* Type hint Correction

* add changeset

* typecheck

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com>
This commit is contained in:
St. HeMeow 2024-08-02 19:52:48 +01:00 committed by GitHub
parent fb502de8af
commit d4c503a471
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": patch
---
feat:Type hint Correction

View File

@ -2,7 +2,7 @@
from __future__ import annotations 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 from gradio_client.documentation import document
@ -29,7 +29,7 @@ class Radio(FormComponent):
| None = None, | None = None,
*, *,
value: str | int | float | Callable | None = None, value: str | int | float | Callable | None = None,
type: str = "value", type: Literal["value", "index"] = "value",
label: str | None = None, label: str | None = None,
info: str | None = None, info: str | None = None,
every: Timer | float | None = None, every: Timer | float | None = None,

View File

@ -49,7 +49,7 @@ class UploadButton(Component):
elem_classes: list[str] | str | None = None, elem_classes: list[str] | str | None = None,
render: bool = True, render: bool = True,
key: int | str | None = None, key: int | str | None = None,
type: Literal["filepath", "bytes"] = "filepath", type: Literal["filepath", "binary"] = "filepath",
file_count: Literal["single", "multiple", "directory"] = "single", file_count: Literal["single", "multiple", "directory"] = "single",
file_types: list[str] | None = None, file_types: list[str] | None = None,
): ):

View File

@ -46,7 +46,7 @@ class TestRadio:
assert radio.choices == [("a", "a"), ("b", "b"), ("c", "c full")] assert radio.choices == [("a", "a"), ("b", "b"), ("c", "c full")]
with pytest.raises(ValueError): with pytest.raises(ValueError):
gr.Radio(["a", "b"], type="unknown") gr.Radio(["a", "b"], type="unknown") # type: ignore
def test_in_interface(self): def test_in_interface(self):
""" """