Skip to content

Commit 3bd4c4b

Browse files
committed
more robust type checking for Numeric digits argument
1 parent 27242ac commit 3bd4c4b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

piccolo/columns/column_types.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,16 @@ def __init__(
466466
default: t.Union[decimal.Decimal, None] = decimal.Decimal(0.0),
467467
**kwargs,
468468
) -> None:
469-
if isinstance(digits, tuple) and len(digits) != 2:
470-
raise ValueError(
471-
"The `digits` argument should be a tuple of length 2, with "
472-
"the first value being the precision, and the second value "
473-
"being the scale."
474-
)
469+
if isinstance(digits, tuple):
470+
if len(digits) != 2:
471+
raise ValueError(
472+
"The `digits` argument should be a tuple of length 2, "
473+
"with the first value being the precision, and the second "
474+
"value being the scale."
475+
)
476+
else:
477+
if digits is not None:
478+
raise ValueError("The digits argument should be a tuple.")
475479

476480
self._validate_default(default, (decimal.Decimal, None))
477481

0 commit comments

Comments
 (0)