Simplify repetitive unequal checks

An if statement with multiple unequal comparisons for the same variable
can be written with a list. This is more elegant and increases
readability.

Change-Id: I3cdf7af1c8b872e943be1d438663b1fc112fc19c
This commit is contained in:
Raildo Mascena 2016-02-17 11:24:36 -03:00 committed by Raildo Mascena
parent f738b28167
commit d14fba6309
1 changed files with 3 additions and 3 deletions

View File

@ -29,9 +29,9 @@ from keystone.trust import schema
def _trustor_trustee_only(trust, user_id):
if (user_id != trust.get('trustee_user_id') and
user_id != trust.get('trustor_user_id')):
raise exception.Forbidden()
if user_id not in [trust.get('trustee_user_id'),
trust.get('trustor_user_id')]:
raise exception.Forbidden()
def _admin_trustor_only(context, trust, user_id):