From 0f7307ca24683ba165830de9fd85f1defc653157 Mon Sep 17 00:00:00 2001 From: James Hilton-Balfe Date: Mon, 11 Apr 2022 21:13:30 +0100 Subject: [PATCH 1/3] Fix comparision with nan Also fixed some typos in the docstrings --- src/betterproto/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/betterproto/__init__.py b/src/betterproto/__init__.py index e6af1bcb8..caed82f8f 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 math.isnan(value): return NAN return value From 9e88585917a0721bb3ad8aa37847a5288ad0b14e Mon Sep 17 00:00:00 2001 From: James Hilton-Balfe Date: Fri, 22 Apr 2022 10:46:47 +0100 Subject: [PATCH 2/3] Update src/betterproto/__init__.py Co-authored-by: Arun Babu Neelicattu --- src/betterproto/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/betterproto/__init__.py b/src/betterproto/__init__.py index caed82f8f..2faa12236 100644 --- a/src/betterproto/__init__.py +++ b/src/betterproto/__init__.py @@ -467,7 +467,7 @@ def _dump_float(value: float) -> Union[float, str]: return INFINITY if value == -float("inf"): return NEG_INFINITY - if math.isnan(value): + if isinstance(value, float) and math.isnan(value): return NAN return value From 757cdec613a00368a8564c3df0f9bb98fbc5d053 Mon Sep 17 00:00:00 2001 From: James Hilton-Balfe Date: Fri, 22 Apr 2022 11:00:26 +0100 Subject: [PATCH 3/3] Quick sneaky update pre-commit version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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