Skip to content

Commit ca8ab1b

Browse files
committed
Minor styling refactoring
1 parent 32395f0 commit ca8ab1b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

flask_parameter_validation/parameter_validation.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def validate(self, expected_input, all_request_inputs):
194194
user_inputs = [user_input]
195195
# If typing.List in union and user supplied valid list, convert remaining check only for list
196196
for exp_type in expected_input_types:
197-
if True in [str(exp_type).startswith(list_hint) for list_hint in list_type_hints]:
197+
if any(str(exp_type).startswith(list_hint) for list_hint in list_type_hints):
198198
if type(user_input) is list:
199199
# Only convert if validation passes
200200
if hasattr(exp_type, "__args__"):
@@ -204,7 +204,7 @@ def validate(self, expected_input, all_request_inputs):
204204
expected_input_type_str = str(exp_type)
205205
user_inputs = user_input
206206
# If list, expand inner typing items. Otherwise, convert to list to match anyway.
207-
elif True in [expected_input_type_str.startswith(list_hint) for list_hint in list_type_hints]:
207+
elif any(expected_input_type_str.startswith(list_hint) for list_hint in list_type_hints):
208208
expected_input_types = expected_input_type.__args__
209209
if type(user_input) is list:
210210
user_inputs = user_input
@@ -229,7 +229,7 @@ def validate(self, expected_input, all_request_inputs):
229229
)
230230

231231
# Validate that if lists are required, lists are given
232-
if True in [expected_input_type_str.startswith(list_hint) for list_hint in list_type_hints]:
232+
if any(expected_input_type_str.startswith(list_hint) for list_hint in list_type_hints):
233233
if type(user_input) is not list:
234234
validation_success = False
235235

@@ -257,6 +257,6 @@ def validate(self, expected_input, all_request_inputs):
257257
raise ValidationError(str(e), expected_name, expected_input_type)
258258

259259
# Return input back to parent function
260-
if True in [expected_input_type_str.startswith(list_hint) for list_hint in list_type_hints]:
260+
if any(expected_input_type_str.startswith(list_hint) for list_hint in list_type_hints):
261261
return user_inputs
262262
return user_inputs[0]

0 commit comments

Comments
 (0)