Use Any if JsonValue cannot be imported (#8336)

* Add fallback

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Freddy Boulton 2024-05-20 15:13:17 -04:00 committed by GitHub
parent 0236b1ab12
commit f138b4159e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": patch
---
fix:Use Any if JsonValue cannot be imported

View File

@ -16,7 +16,12 @@ from gradio_client.utils import traverse
from . import wasm_utils
if not wasm_utils.IS_WASM or TYPE_CHECKING:
from pydantic import BaseModel, JsonValue, RootModel, ValidationError
from pydantic import BaseModel, RootModel, ValidationError
try:
from pydantic import JsonValue
except ImportError:
JsonValue = Any
else:
# XXX: Currently Pyodide V2 is not available on Pyodide,
# so we install V1 for the Wasm version.