Skip to content

Commit 50c1350

Browse files
committed
Change the default of the check_type(optional=)
Change the default value of the `check_type(optional=)` parameter from `True` to `False`. It will be clearer to indicate which items are optional (may be `None`) and which must be one of the acceptable types.
1 parent 3f7ec7a commit 50c1350

File tree

14 files changed

+87
-87
lines changed

14 files changed

+87
-87
lines changed

webexteamssdk/api/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
122122
access_token argument or an environment variable.
123123
124124
"""
125-
check_type(access_token, basestring)
126-
check_type(base_url, basestring)
127-
check_type(single_request_timeout, int)
128-
check_type(wait_on_rate_limit, bool)
125+
check_type(access_token, basestring, optional=True)
126+
check_type(base_url, basestring, optional=True)
127+
check_type(single_request_timeout, int, optional=True)
128+
check_type(wait_on_rate_limit, bool, optional=True)
129129
check_type(client_id, basestring, optional=True)
130130
check_type(client_secret, basestring, optional=True)
131131
check_type(oauth_code, basestring, optional=True)

webexteamssdk/api/access_tokens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, base_url, object_factory, single_request_timeout=None):
8080
8181
"""
8282
check_type(base_url, basestring, optional=False)
83-
check_type(single_request_timeout, int)
83+
check_type(single_request_timeout, int, optional=True)
8484

8585
super(AccessTokensAPI, self).__init__()
8686

webexteamssdk/api/events.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ def list(self, resource=None, type=None, actorId=None, _from=None, to=None,
118118
ApiError: If the Webex Teams cloud returns an error.
119119
120120
"""
121-
check_type(resource, basestring)
122-
check_type(type, basestring)
123-
check_type(actorId, basestring)
124-
check_type(_from, basestring)
125-
check_type(to, basestring)
126-
check_type(max, int)
121+
check_type(resource, basestring, optional=True)
122+
check_type(type, basestring, optional=True)
123+
check_type(actorId, basestring, optional=True)
124+
check_type(_from, basestring, optional=True)
125+
check_type(to, basestring, optional=True)
126+
check_type(max, int, optional=True)
127127

128128
params = dict_from_items_with_values(
129129
request_parameters,

webexteamssdk/api/guest_issuer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, session, object_factory):
6969
Raises:
7070
TypeError: If the parameter types are incorrect
7171
"""
72-
check_type(session, RestSession)
72+
check_type(session, RestSession, optional=True)
7373

7474
super(GuestIssuerAPI, self).__init__()
7575

@@ -95,11 +95,11 @@ def create(self, subject, displayName, issuerToken, expiration, secret):
9595
TypeError: If the parameter types are incorrect
9696
ApiError: If the webex teams cloud returns an error.
9797
"""
98-
check_type(subject, basestring)
99-
check_type(displayName, basestring)
100-
check_type(issuerToken, basestring)
101-
check_type(expiration, basestring)
102-
check_type(secret, basestring)
98+
check_type(subject, basestring, optional=True)
99+
check_type(displayName, basestring, optional=True)
100+
check_type(issuerToken, basestring, optional=True)
101+
check_type(expiration, basestring, optional=True)
102+
check_type(secret, basestring, optional=True)
103103

104104
payload = {
105105
"sub": subject,

webexteamssdk/api/licenses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def list(self, orgId=None, **request_parameters):
9393
ApiError: If the Webex Teams cloud returns an error.
9494
9595
"""
96-
check_type(orgId, basestring)
96+
check_type(orgId, basestring, optional=True)
9797

9898
params = dict_from_items_with_values(
9999
request_parameters,

webexteamssdk/api/memberships.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, session, object_factory):
6565
TypeError: If the parameter types are incorrect.
6666
6767
"""
68-
check_type(session, RestSession)
68+
check_type(session, RestSession, optional=True)
6969

7070
super(MembershipsAPI, self).__init__()
7171

@@ -115,10 +115,10 @@ def list(self, roomId=None, personId=None, personEmail=None, max=None,
115115
ApiError: If the Webex Teams cloud returns an error.
116116
117117
"""
118-
check_type(roomId, basestring)
119-
check_type(personId, basestring)
120-
check_type(personEmail, basestring)
121-
check_type(max, int)
118+
check_type(roomId, basestring, optional=True)
119+
check_type(personId, basestring, optional=True)
120+
check_type(personEmail, basestring, optional=True)
121+
check_type(max, int, optional=True)
122122

123123
params = dict_from_items_with_values(
124124
request_parameters,
@@ -160,9 +160,9 @@ def create(self, roomId, personId=None, personEmail=None,
160160
161161
"""
162162
check_type(roomId, basestring, optional=False)
163-
check_type(personId, basestring)
164-
check_type(personEmail, basestring)
165-
check_type(isModerator, bool)
163+
check_type(personId, basestring, optional=True)
164+
check_type(personEmail, basestring, optional=True)
165+
check_type(isModerator, bool, optional=True)
166166

167167
post_data = dict_from_items_with_values(
168168
request_parameters,
@@ -220,7 +220,7 @@ def update(self, membershipId, isModerator=None, **request_parameters):
220220
221221
"""
222222
check_type(membershipId, basestring, optional=False)
223-
check_type(isModerator, bool)
223+
check_type(isModerator, bool, optional=True)
224224

225225
put_data = dict_from_items_with_values(
226226
request_parameters,
@@ -248,4 +248,4 @@ def delete(self, membershipId):
248248
check_type(membershipId, basestring)
249249

250250
# API request
251-
self._session.delete(API_ENDPOINT + '/' + membershipId)
251+
self._session.delete(API_ENDPOINT + '/' + membershipId, optional=True)

webexteamssdk/api/messages.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ def list(self, roomId, mentionedPeople=None, before=None,
113113
114114
"""
115115
check_type(roomId, basestring, optional=False)
116-
check_type(mentionedPeople, basestring)
117-
check_type(before, basestring)
118-
check_type(beforeMessage, basestring)
119-
check_type(max, int)
116+
check_type(mentionedPeople, basestring, optional=True)
117+
check_type(before, basestring, optional=True)
118+
check_type(beforeMessage, basestring, optional=True)
119+
check_type(max, int, optional=True)
120120

121121
params = dict_from_items_with_values(
122122
request_parameters,
@@ -171,22 +171,22 @@ def create(self, roomId=None, toPersonId=None, toPersonEmail=None,
171171
contain a valid URL or path to a local file.
172172
173173
"""
174-
check_type(roomId, basestring)
175-
check_type(toPersonId, basestring)
176-
check_type(toPersonEmail, basestring)
177-
check_type(text, basestring)
178-
check_type(markdown, basestring)
179-
check_type(files, list)
174+
check_type(roomId, basestring, optional=True)
175+
check_type(toPersonId, basestring, optional=True)
176+
check_type(toPersonEmail, basestring, optional=True)
177+
check_type(text, basestring, optional=True)
178+
check_type(markdown, basestring, optional=True)
179+
check_type(files, list, optional=True)
180180
check_type(attachments, list)
181181
if files:
182182
if len(files) != 1:
183183
raise ValueError("The length of the `files` list is greater "
184-
"than one (1). The files parameter is a "
184+
"than one (1, optional=True). The files parameter is a "
185185
"list, which accepts multiple values to "
186186
"allow for future expansion, but currently "
187187
"only one file may be included with the "
188188
"message.")
189-
check_type(files[0], basestring)
189+
check_type(files[0], basestring, optional=True)
190190

191191
if attachments:
192192
for attachment in attachments:

webexteamssdk/api/people.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, session, object_factory):
6565
TypeError: If the parameter types are incorrect.
6666
6767
"""
68-
check_type(session, RestSession)
68+
check_type(session, RestSession, optional=True)
6969

7070
super(PeopleAPI, self).__init__()
7171

@@ -108,11 +108,11 @@ def list(self, email=None, displayName=None, id=None, orgId=None, max=None,
108108
ApiError: If the Webex Teams cloud returns an error.
109109
110110
"""
111-
check_type(id, basestring)
112-
check_type(email, basestring)
113-
check_type(displayName, basestring)
114-
check_type(orgId, basestring)
115-
check_type(max, int)
111+
check_type(id, basestring, optional=True)
112+
check_type(email, basestring, optional=True)
113+
check_type(displayName, basestring, optional=True)
114+
check_type(orgId, basestring, optional=True)
115+
check_type(max, int, optional=True)
116116

117117
params = dict_from_items_with_values(
118118
request_parameters,
@@ -162,13 +162,13 @@ def create(self, emails, displayName=None, firstName=None, lastName=None,
162162
163163
"""
164164
check_type(emails, list, optional=False)
165-
check_type(displayName, basestring)
166-
check_type(firstName, basestring)
167-
check_type(lastName, basestring)
168-
check_type(avatar, basestring)
169-
check_type(orgId, basestring)
170-
check_type(roles, list)
171-
check_type(licenses, list)
165+
check_type(displayName, basestring, optional=True)
166+
check_type(firstName, basestring, optional=True)
167+
check_type(lastName, basestring, optional=True)
168+
check_type(avatar, basestring, optional=True)
169+
check_type(orgId, basestring, optional=True)
170+
check_type(roles, list, optional=True)
171+
check_type(licenses, list, optional=True)
172172

173173
post_data = dict_from_items_with_values(
174174
request_parameters,
@@ -249,14 +249,14 @@ def update(self, personId, emails=None, displayName=None, firstName=None,
249249
ApiError: If the Webex Teams cloud returns an error.
250250
251251
"""
252-
check_type(emails, list)
253-
check_type(displayName, basestring)
254-
check_type(firstName, basestring)
255-
check_type(lastName, basestring)
256-
check_type(avatar, basestring)
257-
check_type(orgId, basestring)
258-
check_type(roles, list)
259-
check_type(licenses, list)
252+
check_type(emails, list, optional=True)
253+
check_type(displayName, basestring, optional=True)
254+
check_type(firstName, basestring, optional=True)
255+
check_type(lastName, basestring, optional=True)
256+
check_type(avatar, basestring, optional=True)
257+
check_type(orgId, basestring, optional=True)
258+
check_type(roles, list, optional=True)
259+
check_type(licenses, list, optional=True)
260260

261261
put_data = dict_from_items_with_values(
262262
request_parameters,

webexteamssdk/api/rooms.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ def list(self, teamId=None, type=None, sortBy=None, max=None,
112112
ApiError: If the Webex Teams cloud returns an error.
113113
114114
"""
115-
check_type(teamId, basestring)
116-
check_type(type, basestring)
117-
check_type(sortBy, basestring)
118-
check_type(max, int)
115+
check_type(teamId, basestring, optional=True)
116+
check_type(type, basestring, optional=True)
117+
check_type(sortBy, basestring, optional=True)
118+
check_type(max, int, optional=True)
119119

120120
params = dict_from_items_with_values(
121121
request_parameters,
@@ -152,8 +152,8 @@ def create(self, title, teamId=None, **request_parameters):
152152
ApiError: If the Webex Teams cloud returns an error.
153153
154154
"""
155-
check_type(title, basestring)
156-
check_type(teamId, basestring)
155+
check_type(title, basestring, optional=True)
156+
check_type(teamId, basestring, optional=True)
157157

158158
post_data = dict_from_items_with_values(
159159
request_parameters,
@@ -207,7 +207,7 @@ def update(self, roomId, title=None, **request_parameters):
207207
208208
"""
209209
check_type(roomId, basestring, optional=False)
210-
check_type(roomId, basestring)
210+
check_type(roomId, basestring, optional=True)
211211

212212
put_data = dict_from_items_with_values(
213213
request_parameters,

webexteamssdk/api/team_memberships.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, session, object_factory):
6565
TypeError: If the parameter types are incorrect.
6666
6767
"""
68-
check_type(session, RestSession)
68+
check_type(session, RestSession, optional=True)
6969

7070
super(TeamMembershipsAPI, self).__init__()
7171

@@ -103,7 +103,7 @@ def list(self, teamId, max=None, **request_parameters):
103103
104104
"""
105105
check_type(teamId, basestring, optional=False)
106-
check_type(max, int)
106+
check_type(max, int, optional=True)
107107

108108
params = dict_from_items_with_values(
109109
request_parameters,
@@ -144,9 +144,9 @@ def create(self, teamId, personId=None, personEmail=None,
144144
145145
"""
146146
check_type(teamId, basestring, optional=False)
147-
check_type(personId, basestring)
148-
check_type(personEmail, basestring)
149-
check_type(isModerator, bool)
147+
check_type(personId, basestring, optional=True)
148+
check_type(personEmail, basestring, optional=True)
149+
check_type(isModerator, bool, optional=True)
150150

151151
post_data = dict_from_items_with_values(
152152
request_parameters,
@@ -204,7 +204,7 @@ def update(self, membershipId, isModerator=None, **request_parameters):
204204
205205
"""
206206
check_type(membershipId, basestring, optional=False)
207-
check_type(isModerator, bool)
207+
check_type(isModerator, bool, optional=True)
208208

209209
put_data = dict_from_items_with_values(
210210
request_parameters,

0 commit comments

Comments
 (0)