diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3d2fbf502..ed258a08f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 22.1.0 + rev: 22.3.0 hooks: - id: black diff --git a/src/betterproto/__init__.py b/src/betterproto/__init__.py index e6af1bcb8..2faa12236 100644 --- a/src/betterproto/__init__.py +++ b/src/betterproto/__init__.py @@ -433,7 +433,7 @@ def _parse_float(value: Any) -> float: Parameters ---------- - value : Any + value: Any Value to parse Returns @@ -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 isinstance(value, float) and math.isnan(value): return NAN return value