MCPcopy Create free account
hub / github.com/encode/starlette / FloatConvertor

Class FloatConvertor

starlette/convertors.py:55–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54
55class 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
69class UUIDConvertor(Convertor[uuid.UUID]):

Callers 1

convertors.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected