From ce3d0bf2fcd01d0dfcd9359ff808dd828912a31f Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Mon, 13 Mar 2023 12:15:39 +0100 Subject: [PATCH] Silence mypy error Staring with mypy 1.1.1, mypy started complaining about `__new__` of for example `Tuple[float, ...]`, which we are using in spatial and temporal types. --- src/neo4j/_spatial/__init__.py | 5 ++++- src/neo4j/time/__init__.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/neo4j/_spatial/__init__.py b/src/neo4j/_spatial/__init__.py index 0dd91ba75..61a521c60 100644 --- a/src/neo4j/_spatial/__init__.py +++ b/src/neo4j/_spatial/__init__.py @@ -60,7 +60,10 @@ def y(self) -> float: ... def z(self) -> float: ... def __new__(cls, iterable: t.Iterable[float]) -> Point: - return tuple.__new__(cls, map(float, iterable)) + # mypy issue https://github.com/python/mypy/issues/14890 + return tuple.__new__( # type: ignore[type-var] + cls, map(float, iterable) + ) def __repr__(self) -> str: return "POINT(%s)" % " ".join(map(str, self)) diff --git a/src/neo4j/time/__init__.py b/src/neo4j/time/__init__.py index faf8061c8..29fc4f725 100644 --- a/src/neo4j/time/__init__.py +++ b/src/neo4j/time/__init__.py @@ -415,7 +415,8 @@ def __new__( if not MIN_INT64 <= avg_total_seconds <= MAX_INT64: raise ValueError("Duration value out of range: %r", tuple.__repr__((mo, d, s, ns))) - return tuple.__new__(cls, (mo, d, s, ns)) + # mypy issue https://github.com/python/mypy/issues/14890 + return tuple.__new__(cls, (mo, d, s, ns)) # type: ignore[type-var] def __bool__(self) -> bool: """Falsy if all primary instance attributes are."""