| 53 | |
| 54 | |
| 55 | class FloatConvertor(Convertor[float]): |
| 56 | regex = r"[0-9]+(\.[0-9]+)?" |
| 57 | |
| 58 | def convert(self, value: str) -> float: |
| 59 | return float(value) |
| 60 | |
| 61 | def to_string(self, value: float) -> str: |
| 62 | value = float(value) |
| 63 | assert value >= 0.0, "Negative floats are not supported" |
| 64 | assert not math.isnan(value), "NaN values are not supported" |
| 65 | assert not math.isinf(value), "Infinite values are not supported" |
| 66 | return ("%0.20f" % value).rstrip("0").rstrip(".") |
| 67 | |
| 68 | |
| 69 | class UUIDConvertor(Convertor[uuid.UUID]): |