MCPcopy
hub / github.com/danielgtaylor/python-betterproto / _dump_float

Function _dump_float

src/betterproto/__init__.py:533–552  ·  view source on GitHub ↗

Dump the given float to JSON Parameters ---------- value: float Value to dump Returns ------- Union[float, str] Dumped value, either a float or the strings

(value: float)

Source from the content-addressed store, hash-verified

531
532
533def _dump_float(value: float) -> Union[float, str]:
534 """Dump the given float to JSON
535
536 Parameters
537 ----------
538 value: float
539 Value to dump
540
541 Returns
542 -------
543 Union[float, str]
544 Dumped value, either a float or the strings
545 """
546 if value == float("inf"):
547 return INFINITY
548 if value == -float("inf"):
549 return NEG_INFINITY
550 if isinstance(value, float) and math.isnan(value):
551 return NAN
552 return value
553
554
555def load_varint(stream: "SupportsRead[bytes]") -> Tuple[int, bytes]:

Callers 1

to_dictMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected