Consider merging these comparisons with "in" to "ticket.type in ('paid', 'donation')"
250 :param view_kwargs:
251 :return:
252 """
253 if ticket.type == 'paid' or ticket.type == 'donation':254 try:
255 event = (
256 db.session.query(Event)
Consider merging these comparisons with "in" to "data.get('type') in ('paid', 'donation')"
96 {'event_id': data['event']}, "Event does not exist"
97 )
98
99 if data.get('type') == 'paid' or data.get('type') == 'donation':100 if not event.is_payment_enabled():
101 raise UnprocessableEntityError(
102 {'event_id': data['event']},
Consider merging these comparisons with "in" to "order.status in ('cancelled', 'expired', 'completed')"
33 ),
34 )
35 if (
36 order.status == 'cancelled'37 or order.status == 'expired'
38 or order.status == 'completed'
39 ):
Description
To check if a variable is equal to one of many values, combine the values into a tuple and check if the variable is contained in
it instead of checking for equality against each of the values.
This is faster, less verbose, and more readable.
Bad practice
if x == 1 or x == 2 or x == 3:
do_something()
Recommended
if x in (1, 2, 3):
do_something()