92
92
93
93
if TYPE_CHECKING:
94
94
from collections.abc import Collection
95
+ from typing import Any
95
96
96
97
from pointblank._typing import AbsoluteBounds, Tolerance
97
98
@@ -1896,12 +1897,12 @@ class _ValidationInfo:
1896
1897
step_id: str | None = None
1897
1898
sha1: str | None = None
1898
1899
assertion_type: str | None = None
1899
- column: any | None = None
1900
- values: any | list[any] | tuple | None = None
1900
+ column: Any | None = None
1901
+ values: Any | list[any] | tuple | None = None
1901
1902
inclusive: tuple[bool, bool] | None = None
1902
1903
na_pass: bool | None = None
1903
1904
pre: Callable | None = None
1904
- segments: any | None = None
1905
+ segments: Any | None = None
1905
1906
thresholds: Thresholds | None = None
1906
1907
actions: Actions | None = None
1907
1908
label: str | None = None
@@ -5964,7 +5965,7 @@ def col_vals_regex(
5964
5965
5965
5966
def col_vals_expr(
5966
5967
self,
5967
- expr: any ,
5968
+ expr: Any ,
5968
5969
pre: Callable | None = None,
5969
5970
segments: SegmentSpec | None = None,
5970
5971
thresholds: int | float | bool | tuple | dict | Thresholds = None,
@@ -11953,7 +11954,7 @@ def _convert_string_to_datetime(value: str) -> datetime.datetime:
11953
11954
return datetime.datetime.strptime(value, "%Y-%m-%d %H:%M:%S")
11954
11955
11955
11956
11956
- def _string_date_dttm_conversion(value: any ) -> any :
11957
+ def _string_date_dttm_conversion(value: Any ) -> Any :
11957
11958
"""
11958
11959
Convert a string to a date or datetime object if it is in the correct format.
11959
11960
If the value is not a string, it is returned as is.
@@ -11991,9 +11992,9 @@ def _process_brief(
11991
11992
brief: str | None,
11992
11993
step: int,
11993
11994
col: str | list[str] | None,
11994
- values: any | None,
11995
- thresholds: any | None,
11996
- segment: any | None,
11995
+ values: Any | None,
11996
+ thresholds: Any | None,
11997
+ segment: Any | None,
11997
11998
) -> str:
11998
11999
# If there is no brief, return `None`
11999
12000
if brief is None:
@@ -12059,7 +12060,7 @@ def _process_action_str(
12059
12060
action_str: str,
12060
12061
step: int,
12061
12062
col: str | None,
12062
- value: any ,
12063
+ value: Any ,
12063
12064
type: str,
12064
12065
level: str,
12065
12066
time: str,
@@ -12506,7 +12507,7 @@ def _prep_values_text(
12506
12507
return values_str
12507
12508
12508
12509
12509
- def _seg_expr_from_string(data_tbl: any , segments_expr: str) -> tuple[str, str]:
12510
+ def _seg_expr_from_string(data_tbl: Any , segments_expr: str) -> tuple[str, str]:
12510
12511
"""
12511
12512
Obtain the segmentation categories from a table column.
12512
12513
@@ -12598,7 +12599,7 @@ def _seg_expr_from_tuple(segments_expr: tuple) -> list[tuple[str, str]]:
12598
12599
return seg_tuples
12599
12600
12600
12601
12601
- def _apply_segments(data_tbl: any , segments_expr: tuple[str, str]) -> any :
12602
+ def _apply_segments(data_tbl: Any , segments_expr: tuple[str, str]) -> Any :
12602
12603
"""
12603
12604
Apply the segments expression to the data table.
12604
12605
@@ -12782,7 +12783,7 @@ def _process_title_text(title: str | None, tbl_name: str | None, lang: str) -> s
12782
12783
return title_text
12783
12784
12784
12785
12785
- def _transform_tbl_preprocessed(pre: any , seg: any , interrogation_performed: bool) -> list[str]:
12786
+ def _transform_tbl_preprocessed(pre: Any , seg: Any , interrogation_performed: bool) -> list[str]:
12786
12787
# If no interrogation was performed, return a list of empty strings
12787
12788
if not interrogation_performed:
12788
12789
return ["" for _ in range(len(pre))]
@@ -12999,16 +13000,14 @@ def _pre_processing_funcs_to_str(pre: Callable) -> str | list[str]:
12999
13000
13000
13001
13001
13002
def _get_callable_source(fn: Callable) -> str:
13002
- if isinstance(fn, Callable):
13003
- try:
13004
- source_lines, _ = inspect.getsourcelines(fn)
13005
- source = "".join(source_lines).strip()
13006
- # Extract the `pre` argument from the source code
13007
- pre_arg = _extract_pre_argument(source)
13008
- return pre_arg
13009
- except (OSError, TypeError): # pragma: no cover
13010
- return fn.__name__
13011
- return fn
13003
+ try:
13004
+ source_lines, _ = inspect.getsourcelines(fn)
13005
+ source = "".join(source_lines).strip()
13006
+ # Extract the `pre` argument from the source code
13007
+ pre_arg = _extract_pre_argument(source)
13008
+ return pre_arg
13009
+ except (OSError, TypeError): # pragma: no cover
13010
+ return fn.__name__
13012
13011
13013
13012
13014
13013
def _extract_pre_argument(source: str) -> str:
@@ -13034,6 +13033,7 @@ def _create_table_time_html(
13034
13033
if time_start is None:
13035
13034
return ""
13036
13035
13036
+ assert time_end is not None # typing
13037
13037
# Get the time duration (difference between `time_end` and `time_start`) in seconds
13038
13038
time_duration = (time_end - time_start).total_seconds()
13039
13039
@@ -13170,12 +13170,12 @@ def _step_report_row_based(
13170
13170
column: str,
13171
13171
column_position: int,
13172
13172
columns_subset: list[str] | None,
13173
- values: any ,
13173
+ values: Any ,
13174
13174
inclusive: tuple[bool, bool] | None,
13175
13175
n: int,
13176
13176
n_failed: int,
13177
13177
all_passed: bool,
13178
- extract: any ,
13178
+ extract: Any ,
13179
13179
tbl_preview: GT,
13180
13180
header: str,
13181
13181
limit: int | None,
@@ -13202,10 +13202,12 @@ def _step_report_row_based(
13202
13202
elif assertion_type == "col_vals_le":
13203
13203
text = f"{column} ≤ {values}"
13204
13204
elif assertion_type == "col_vals_between":
13205
+ assert inclusive is not None
13205
13206
symbol_left = "≤" if inclusive[0] else "<"
13206
13207
symbol_right = "≤" if inclusive[1] else "<"
13207
13208
text = f"{values[0]} {symbol_left} {column} {symbol_right} {values[1]}"
13208
13209
elif assertion_type == "col_vals_outside":
13210
+ assert inclusive is not None
13209
13211
symbol_left = "<" if inclusive[0] else "≤"
13210
13212
symbol_right = ">" if inclusive[1] else "≥"
13211
13213
text = f"{column} {symbol_left} {values[0]}, {column} {symbol_right} {values[1]}"
@@ -13410,7 +13412,7 @@ def _step_report_rows_distinct(
13410
13412
n: int,
13411
13413
n_failed: int,
13412
13414
all_passed: bool,
13413
- extract: any ,
13415
+ extract: Any ,
13414
13416
tbl_preview: GT,
13415
13417
header: str,
13416
13418
limit: int | None,
@@ -13538,7 +13540,7 @@ def _step_report_rows_distinct(
13538
13540
13539
13541
def _step_report_schema_in_order(
13540
13542
step: int, schema_info: dict, header: str, lang: str, debug_return_df: bool = False
13541
- ) -> GT | any :
13543
+ ) -> GT | Any :
13542
13544
"""
13543
13545
This is the case for schema validation where the schema is supposed to have the same column
13544
13546
order as the target table.
@@ -13877,7 +13879,7 @@ def _step_report_schema_in_order(
13877
13879
13878
13880
def _step_report_schema_any_order(
13879
13881
step: int, schema_info: dict, header: str, lang: str, debug_return_df: bool = False
13880
- ) -> GT | any :
13882
+ ) -> GT | Any :
13881
13883
"""
13882
13884
This is the case for schema validation where the schema is permitted to not have to be in the
13883
13885
same column order as the target table.
0 commit comments