Skip to content

Commit

Permalink
use isinstance() in types checks instead of exact types checks
Browse files Browse the repository at this point in the history
  • Loading branch information
denisri committed May 5, 2020
1 parent ada0411 commit fe09684
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/populse_db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,20 +1630,20 @@ 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
if valid_type == FIELD_TYPE_TIME and value_type == time:
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
Expand Down

0 comments on commit fe09684

Please sign in to comment.