glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL
https://app.quicktype.io
Apache License 2.0
11.77k stars 1.04k forks source link

fix(Python): update to_float output for Python #2549

Closed inferrinizzard closed 2 months ago

inferrinizzard commented 3 months ago

Description

Allows for int types in to_float for Python output

Related Issue

Fixes #2533

Previous Behaviour / Output

existing to_float output:

def to_float(x: Any) -> float:
    assert isinstance(x, float)
    return x

New Behaviour / Output

newto_float output:

def to_float(x: Any) -> float:
    assert isinstance(x, (int, float))
    return x

How Has This Been Tested?

Screenshots (if appropriate):

N/a