Skip to content

Commit

Permalink
Fix missing exception raise in _val_is_numeric() and _val_is_str() (
Browse files Browse the repository at this point in the history
#510)

* Raise `ValueError` in `_val_is_numeric()` and `_val_is_str()`

* Update tests
  • Loading branch information
jrycw authored Nov 23, 2024
1 parent 549f668 commit 4771178
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions great_tables/_utils_nanoplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _val_is_numeric(x: Any) -> bool:

# If a list then signal a failure
if isinstance(x, list):
ValueError("The input cannot be a list. It must be a single value.")
raise ValueError("The input cannot be a list. It must be a single value.")

return isinstance(x, (int, float))

Expand All @@ -38,7 +38,7 @@ def _val_is_str(x: Any) -> bool:

# If a list then signal a failure
if isinstance(x, list):
ValueError("The input cannot be a list. It must be a single value.")
raise ValueError("The input cannot be a list. It must be a single value.")

return isinstance(x, (str))

Expand Down
2 changes: 0 additions & 2 deletions tests/test__utils_nanoplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def test_val_is_numeric():
assert not _val_is_numeric("a")


@pytest.mark.xfail
def test_val_is_numeric_fails_list_input():
with pytest.raises(ValueError):
_val_is_numeric([1, 2, 3])
Expand All @@ -88,7 +87,6 @@ def test_val_is_str():
assert not _val_is_str(1)


@pytest.mark.xfail
def test_val_is_str_fails_list_input():
with pytest.raises(ValueError):
_val_is_str(["a", "b", "c"])
Expand Down

0 comments on commit 4771178

Please sign in to comment.