From 1d5c57f4d37f83f72992725f5d93d61b58b6430b Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sat, 11 Jan 2025 17:14:13 +0000 Subject: [PATCH] fix: to_py_scalar was raising for decimals --- narwhals/translate.py | 2 ++ tests/translate/to_py_scalar_test.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/narwhals/translate.py b/narwhals/translate.py index 9ad868016..6ed82326d 100644 --- a/narwhals/translate.py +++ b/narwhals/translate.py @@ -2,6 +2,7 @@ from datetime import datetime from datetime import timedelta +from decimal import Decimal from functools import wraps from typing import TYPE_CHECKING from typing import Any @@ -59,6 +60,7 @@ int, float, complex, + Decimal, ) diff --git a/tests/translate/to_py_scalar_test.py b/tests/translate/to_py_scalar_test.py index ace5db7a6..b85983501 100644 --- a/tests/translate/to_py_scalar_test.py +++ b/tests/translate/to_py_scalar_test.py @@ -2,6 +2,7 @@ from datetime import datetime from datetime import timedelta +from decimal import Decimal from typing import Any import numpy as np @@ -20,6 +21,7 @@ (1, 1), (pa.scalar(1), 1), (np.int64(1), 1), + (Decimal("1.1"), Decimal("1.1")), (1.0, 1.0), (None, None), ("a", "a"),