From fe0968431aaae9899f38a5395f24709ff3a45209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Rivi=C3=A8re?= Date: Tue, 5 May 2020 11:16:42 +0200 Subject: [PATCH] use isinstance() in types checks instead of exact types checks --- python/populse_db/database.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/populse_db/database.py b/python/populse_db/database.py index 991a6ad..961c39f 100644 --- a/python/populse_db/database.py +++ b/python/populse_db/database.py @@ -1630,9 +1630,9 @@ def __check_type_value(value, valid_type): return True if valid_type == FIELD_TYPE_BOOLEAN and value_type == bool: return True - if valid_type == FIELD_TYPE_STRING and value_type == str: + if valid_type == FIELD_TYPE_STRING and isinstance(value, str): return True - if valid_type == FIELD_TYPE_JSON and value_type == dict: + if valid_type == FIELD_TYPE_JSON and isinstance(value, dict): return True if valid_type == FIELD_TYPE_DATETIME and value_type == datetime: return True @@ -1640,10 +1640,10 @@ def __check_type_value(value, valid_type): return True if valid_type == FIELD_TYPE_DATE and value_type == date: return True - if (valid_type in LIST_TYPES - and value_type == list): + if valid_type in LIST_TYPES and isinstance(value, list): for value_element in value: - if not DatabaseSession.__check_type_value(value_element, valid_type.replace("list_", "")): + if not DatabaseSession.__check_type_value( + value_element, valid_type.replace("list_", "")): return False return True return False