From 9c02d413ce31a240d8a0608b4fd52b790aff0287 Mon Sep 17 00:00:00 2001 From: Junho Lee Date: Mon, 24 Jul 2023 21:17:47 -0400 Subject: [PATCH] Make sure random_state is a list before indexed assignment Currently, a mypy error occurs because we attempt to assign to random_state[1] when random_state has type Union[list[Any], tuple[Any]]. Tuples are immutable so this is a type error. We fix this by making random_state into a list before doing indexed assignment on it. --- dataprofiler/labelers/data_processing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dataprofiler/labelers/data_processing.py b/dataprofiler/labelers/data_processing.py index be1a3fee4..1ef95587e 100644 --- a/dataprofiler/labelers/data_processing.py +++ b/dataprofiler/labelers/data_processing.py @@ -1556,7 +1556,8 @@ def __init__( elif isinstance(random_state, (list, tuple)) and len(random_state) == 3: # tuple required for random state to be set, lists do not work if isinstance(random_state[1], list): - random_state[1] = tuple(random_state[1]) # type: ignore + random_state = list(random_state) + random_state[1] = tuple(random_state[1]) if isinstance(random_state, list): random_state = tuple(random_state) temp_random_state = random.Random() @@ -1895,7 +1896,8 @@ def __init__( elif isinstance(random_state, (list, tuple)) and len(random_state) == 3: # tuple required for random state to be set, lists do not work if isinstance(random_state[1], list): - random_state[1] = tuple(random_state[1]) # type: ignore + random_state = list(random_state) + random_state[1] = tuple(random_state[1]) if isinstance(random_state, list): random_state = tuple(random_state) temp_random_state = random.Random()