Skip to content

Commit

Permalink
Fix comparision with nan
Browse files Browse the repository at this point in the history
Also fixed some typos in the docstrings
  • Loading branch information
Gobot1234 authored Apr 11, 2022
1 parent 5f7e4d5 commit 0f7307c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/betterproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def _parse_float(value: Any) -> float:
Parameters
----------
value : Any
value: Any
Value to parse
Returns
Expand All @@ -455,20 +455,19 @@ def _dump_float(value: float) -> Union[float, str]:
Parameters
----------
value : float
value: float
Value to dump
Returns
-------
Union[float, str]
Dumped valid, either a float or the strings
"Infinity" or "-Infinity"
Dumped value, either a float or the strings
"""
if value == float("inf"):
return INFINITY
if value == -float("inf"):
return NEG_INFINITY
if value == float("nan"):
if math.isnan(value):
return NAN
return value

Expand Down

0 comments on commit 0f7307c

Please sign in to comment.