Spaces:
Sleeping
Sleeping
ibcplateformes Claude Opus 4.6 commited on
Commit ·
dbae9aa
1
Parent(s): 0ead6d9
Fix: monkey-patch gradio_client get_type for bool schema crash on Gradio 5.12.0
Browse filesThe same TypeError 'argument of type bool is not iterable' bug exists in
gradio_client/utils.py get_type() when schema is a boolean (e.g. from
additionalProperties: true in JSON schema). Patch get_type and
_json_schema_to_python_type to return 'Any' for non-dict schemas.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -11,6 +11,34 @@ import shutil
|
|
| 11 |
|
| 12 |
import gradio as gr
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Setup logging
|
| 15 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 16 |
logger = logging.getLogger(__name__)
|
|
|
|
| 11 |
|
| 12 |
import gradio as gr
|
| 13 |
|
| 14 |
+
# ── Monkey-patch gradio_client to fix "argument of type 'bool' is not iterable" ──
|
| 15 |
+
# Bug: gradio_client/utils.py get_type() crashes when schema is a bool instead of dict
|
| 16 |
+
try:
|
| 17 |
+
import gradio_client.utils as _gc_utils
|
| 18 |
+
|
| 19 |
+
_orig_get_type = _gc_utils.get_type
|
| 20 |
+
|
| 21 |
+
def _patched_get_type(schema, *args, **kwargs):
|
| 22 |
+
if not isinstance(schema, dict):
|
| 23 |
+
return "Any"
|
| 24 |
+
return _orig_get_type(schema, *args, **kwargs)
|
| 25 |
+
|
| 26 |
+
_gc_utils.get_type = _patched_get_type
|
| 27 |
+
|
| 28 |
+
_orig_json_schema = _gc_utils._json_schema_to_python_type
|
| 29 |
+
|
| 30 |
+
def _patched_json_schema(schema, *args, **kwargs):
|
| 31 |
+
if not isinstance(schema, dict):
|
| 32 |
+
return "Any"
|
| 33 |
+
return _orig_json_schema(schema, *args, **kwargs)
|
| 34 |
+
|
| 35 |
+
_gc_utils._json_schema_to_python_type = _patched_json_schema
|
| 36 |
+
_gc_utils.json_schema_to_python_type = lambda schema, defs=None: _patched_json_schema(
|
| 37 |
+
schema, defs
|
| 38 |
+
)
|
| 39 |
+
except Exception:
|
| 40 |
+
pass
|
| 41 |
+
|
| 42 |
# Setup logging
|
| 43 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 44 |
logger = logging.getLogger(__name__)
|