Skip to content

Commit 7d7c64b

Browse files
committed
change _prep_column_text to only throw if it gets None
1 parent c549787 commit 7d7c64b

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

pointblank/validate.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
from collections.abc import Collection
9595
from typing import Any
9696

97-
from pointblank._typing import AbsoluteBounds, Tolerance
97+
from pointblank._typing import AbsoluteBounds, Tolerance, _CompliantValue, _CompliantValues
9898

9999
__all__ = [
100100
"Validate",
@@ -12110,7 +12110,7 @@ def _process_action_str(
1211012110

1211112111

1211212112
def _create_autobrief_or_failure_text(
12113-
assertion_type: str, lang: str, column: str | None, values: str | None, for_failure: bool
12113+
assertion_type: str, lang: str, column: str, values: str | None, for_failure: bool
1211412114
) -> str:
1211512115
if assertion_type in [
1211612116
"col_vals_gt",
@@ -12250,7 +12250,7 @@ def _expect_failure_type(for_failure: bool) -> str:
1225012250
def _create_text_comparison(
1225112251
assertion_type: str,
1225212252
lang: str,
12253-
column: str | list[str] | None,
12253+
column: str | list[str],
1225412254
values: str | None,
1225512255
for_failure: bool = False,
1225612256
) -> str:
@@ -12276,7 +12276,7 @@ def _create_text_comparison(
1227612276

1227712277
def _create_text_between(
1227812278
lang: str,
12279-
column: str | None,
12279+
column: str,
1228012280
value_1: str,
1228112281
value_2: str,
1228212282
not_: bool = False,
@@ -12306,7 +12306,7 @@ def _create_text_between(
1230612306

1230712307

1230812308
def _create_text_set(
12309-
lang: str, column: str | None, values: list[any], not_: bool = False, for_failure: bool = False
12309+
lang: str, column: str, values: list[any], not_: bool = False, for_failure: bool = False
1231012310
) -> str:
1231112311
type_ = _expect_failure_type(for_failure=for_failure)
1231212312

@@ -12328,9 +12328,7 @@ def _create_text_set(
1232812328
return text
1232912329

1233012330

12331-
def _create_text_null(
12332-
lang: str, column: str | None, not_: bool = False, for_failure: bool = False
12333-
) -> str:
12331+
def _create_text_null(lang: str, column: str, not_: bool = False, for_failure: bool = False) -> str:
1233412332
type_ = _expect_failure_type(for_failure=for_failure)
1233512333

1233612334
column_text = _prep_column_text(column=column)
@@ -12347,9 +12345,7 @@ def _create_text_null(
1234712345
return text
1234812346

1234912347

12350-
def _create_text_regex(
12351-
lang: str, column: str | None, pattern: str, for_failure: bool = False
12352-
) -> str:
12348+
def _create_text_regex(lang: str, column: str, pattern: str, for_failure: bool = False) -> str:
1235312349
type_ = _expect_failure_type(for_failure=for_failure)
1235412350

1235512351
column_text = _prep_column_text(column=column)
@@ -12416,15 +12412,15 @@ def _create_text_rows_complete(
1241612412
return text
1241712413

1241812414

12419-
def _create_text_row_count_match(lang: str, value: int, for_failure: bool = False) -> str:
12415+
def _create_text_row_count_match(lang: str, value: dict, for_failure: bool = False) -> str:
1242012416
type_ = _expect_failure_type(for_failure=for_failure)
1242112417

1242212418
values_text = _prep_values_text(value["count"], lang=lang)
1242312419

1242412420
return EXPECT_FAIL_TEXT[f"row_count_match_n_{type_}_text"][lang].format(values_text=values_text)
1242512421

1242612422

12427-
def _create_text_col_count_match(lang: str, value: int, for_failure: bool = False) -> str:
12423+
def _create_text_col_count_match(lang: str, value: dict, for_failure: bool = False) -> str:
1242812424
type_ = _expect_failure_type(for_failure=for_failure)
1242912425

1243012426
values_text = _prep_values_text(value["count"], lang=lang)
@@ -12447,19 +12443,13 @@ def _create_text_specially(lang: str, for_failure: bool = False) -> str:
1244712443
def _prep_column_text(column: str | list[str]) -> str:
1244812444
if isinstance(column, list):
1244912445
return "`" + str(column[0]) + "`"
12450-
elif isinstance(column, str):
12446+
if isinstance(column, str):
1245112447
return "`" + column + "`"
12452-
else:
12453-
return ""
12448+
raise AssertionError
1245412449

1245512450

1245612451
def _prep_values_text(
12457-
values: str
12458-
| int
12459-
| float
12460-
| datetime.datetime
12461-
| datetime.date
12462-
| list[str | int | float | datetime.datetime | datetime.date],
12452+
values: _CompliantValue | _CompliantValues,
1246312453
lang: str,
1246412454
limit: int = 3,
1246512455
) -> str:

tests/test_validate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10492,4 +10492,6 @@ def test_above_threshold_no_interrogation():
1049210492
def test_prep_column_text():
1049310493
assert _prep_column_text(column="column") == "`column`"
1049410494
assert _prep_column_text(column=["column_a", "column_b"]) == "`column_a`"
10495-
assert _prep_column_text(column=3) == ""
10495+
10496+
with pytest.raises(AssertionError):
10497+
_prep_column_text(column=3)

0 commit comments

Comments
 (0)