From 679387e4ba954bd457b61b8ce5df51263494e6c8 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Tue, 25 Mar 2025 19:27:01 +0100 Subject: [PATCH] Fix(classgen): support number conversion from jsonschema --- pkgs/classgen/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/classgen/main.py b/pkgs/classgen/main.py index d19eaf72e..1d733f3a3 100644 --- a/pkgs/classgen/main.py +++ b/pkgs/classgen/main.py @@ -34,6 +34,10 @@ def map_json_type( return {"int"} if json_type == "boolean": return {"bool"} + # In Python, "number" is analogous to the float type. + # https://json-schema.org/understanding-json-schema/reference/numeric#number + if json_type == "number": + return {"float"} if json_type == "array": assert nested_types, f"Array type not found for {parent}" return {f"""list[{" | ".join(nested_types)}]"""}