Skip to content

Commit 6c3237e

Browse files
committed
Remove the check_all_not_none function and minor updates
Use the Python builtin `all()` function.
1 parent a01103f commit 6c3237e

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

webexteamssdk/api/__init__.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
from webexteamssdk.exceptions import AccessTokenError
3333
from webexteamssdk.models.immutable import immutable_data_factory
3434
from webexteamssdk.restsession import RestSession
35-
from webexteamssdk.utils import check_type, check_all_not_none
35+
from webexteamssdk.utils import check_type
3636
from .access_tokens import AccessTokensAPI
3737
from .events import EventsAPI
38+
from .guest_issuer import GuestIssuerAPI
3839
from .licenses import LicensesAPI
3940
from .memberships import MembershipsAPI
4041
from .messages import MessagesAPI
@@ -45,7 +46,6 @@
4546
from .team_memberships import TeamMembershipsAPI
4647
from .teams import TeamsAPI
4748
from .webhooks import WebhooksAPI
48-
from .guest_issuer import GuestIssuerAPI
4949

5050

5151
class WebexTeamsAPI(object):
@@ -129,19 +129,24 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
129129

130130
access_token = access_token or WEBEX_TEAMS_ACCESS_TOKEN
131131

132-
# Check if the user has provided the required oauth parameters
133-
oauth_param_list = [client_id, client_secret, oauth_code, redirect_uri]
134-
# Init AccessTokensAPI earlier to use for oauth requests
132+
# Init AccessTokensAPI wrapper early to use for oauth requests
135133
self.access_tokens = AccessTokensAPI(
136134
self.base_url, object_factory,
137135
single_request_timeout=single_request_timeout
138136
)
139-
if not access_token and check_all_not_none(oauth_param_list):
140-
access_token = self.access_tokens.get(client_id=client_id,
141-
client_secret=client_secret,
142-
code=oauth_code,
143-
redirect_uri=redirect_uri
144-
).access_token
137+
138+
# Check if the user has provided the required oauth parameters
139+
oauth_param_list = [client_id, client_secret, oauth_code, redirect_uri]
140+
if not access_token and all(oauth_param_list):
141+
access_token = self.access_tokens.get(
142+
client_id=client_id,
143+
client_secret=client_secret,
144+
code=oauth_code,
145+
redirect_uri=redirect_uri
146+
).access_token
147+
148+
# If an access token hasn't been provided as a parameter, environment
149+
# variable, or obtained via an OAuth exchange raise an error.
145150
if not access_token:
146151
raise AccessTokenError(
147152
"You must provide a Webex Teams access token to interact with "

webexteamssdk/utils.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,6 @@ def open_local_file(file_path):
128128
content_type=content_type)
129129

130130

131-
def check_all_not_none(l):
132-
"""Checks if all the elements in the list are not none.
133-
134-
Args:
135-
l(list): A list of objects that should be checked
136-
137-
Returns:
138-
boolean: True if all list items are not none, false otherwise
139-
140-
"""
141-
for o in l:
142-
if o is None:
143-
return False
144-
145-
return True
146-
147-
148131
def check_type(o, acceptable_types, may_be_none=True):
149132
"""Object is an instance of one of the acceptable types or None.
150133

0 commit comments

Comments
 (0)