Skip to content

Commit 6903bfe

Browse files
author
childish-sambino
authored
fix: mark dependents as optional and drop empty path solutions (#688)
Provides for better type checking.
1 parent 2325f29 commit 6903bfe

File tree

519 files changed

+1663
-1964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

519 files changed

+1663
-1964
lines changed

twilio/base/page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Page(object):
2525
"uri",
2626
}
2727

28-
def __init__(self, version, response, solution):
28+
def __init__(self, version, response, solution={}):
2929
payload = self.process_response(response)
3030

3131
self._version = version

twilio/http/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(
2323
**kwargs
2424
):
2525
self.method = method
26-
if method and method != Match.ANY:
26+
if method and method is not Match.ANY:
2727
self.method = method.upper()
2828
self.url = url
2929
self.auth = auth

twilio/rest/accounts/v1/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Do not edit the class manually.
1313
"""
1414

15+
from typing import Optional
1516
from twilio.base.version import Version
1617
from twilio.base.domain import Domain
1718
from twilio.rest.accounts.v1.auth_token_promotion import AuthTokenPromotionList
@@ -27,9 +28,9 @@ def __init__(self, domain: Domain):
2728
:param domain: The Twilio.accounts domain
2829
"""
2930
super().__init__(domain, "v1")
30-
self._auth_token_promotion = None
31-
self._credentials = None
32-
self._secondary_auth_token = None
31+
self._auth_token_promotion: Optional[AuthTokenPromotionList] = None
32+
self._credentials: Optional[CredentialList] = None
33+
self._secondary_auth_token: Optional[SecondaryAuthTokenList] = None
3334

3435
@property
3536
def auth_token_promotion(self) -> AuthTokenPromotionList:

twilio/rest/accounts/v1/auth_token_promotion.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414

1515

16+
from typing import Optional
1617
from twilio.base import deserialize
1718
from twilio.base import values
1819
from twilio.base.instance_context import InstanceContext
@@ -33,9 +34,6 @@ def __init__(self, version: Version):
3334
"""
3435
super().__init__(version)
3536

36-
# Path Solution
37-
self._solution = {}
38-
3937
def get(self):
4038
"""
4139
Constructs a AuthTokenPromotionContext
@@ -84,8 +82,8 @@ def __init__(self, version, payload):
8482
"url": payload.get("url"),
8583
}
8684

87-
self._context = None
8885
self._solution = {}
86+
self._context: Optional[AuthTokenPromotionContext] = None
8987

9088
@property
9189
def _proxy(self):
@@ -185,9 +183,7 @@ def __init__(self, version: Version):
185183
"""
186184
super().__init__(version)
187185

188-
# Path Solution
189-
self._solution = {}
190-
self._uri = "/AuthTokens/Promote".format(**self._solution)
186+
self._uri = "/AuthTokens/Promote"
191187

192188
def update(self):
193189
"""
@@ -232,5 +228,5 @@ def __repr__(self):
232228
:returns: Machine friendly representation
233229
:rtype: str
234230
"""
235-
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
236-
return "<Twilio.Accounts.V1.AuthTokenPromotionContext {}>".format(context)
231+
232+
return "<Twilio.Accounts.V1.AuthTokenPromotionContext>"

twilio/rest/accounts/v1/credential/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"""
1414

1515

16+
from typing import Optional
17+
18+
1619
from twilio.base.list_resource import ListResource
1720
from twilio.base.version import Version
1821

@@ -32,12 +35,10 @@ def __init__(self, version: Version):
3235
"""
3336
super().__init__(version)
3437

35-
# Path Solution
36-
self._solution = {}
37-
self._uri = "/Credentials".format(**self._solution)
38+
self._uri = "/Credentials"
3839

39-
self._aws = None
40-
self._public_key = None
40+
self._aws: Optional[AwsList] = None
41+
self._public_key: Optional[PublicKeyList] = None
4142

4243
@property
4344
def aws(self):

twilio/rest/accounts/v1/credential/aws.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def __init__(self, version: Version):
3535
"""
3636
super().__init__(version)
3737

38-
# Path Solution
39-
self._solution = {}
40-
self._uri = "/Credentials/AWS".format(**self._solution)
38+
self._uri = "/Credentials/AWS"
4139

4240
def create(self, credentials, friendly_name=values.unset, account_sid=values.unset):
4341
"""
@@ -208,7 +206,7 @@ def page(
208206
)
209207

210208
response = self._version.page(method="GET", uri=self._uri, params=data)
211-
return AwsPage(self._version, response, self._solution)
209+
return AwsPage(self._version, response)
212210

213211
async def page_async(
214212
self, page_token=values.unset, page_number=values.unset, page_size=values.unset
@@ -235,7 +233,7 @@ async def page_async(
235233
response = await self._version.page_async(
236234
method="GET", uri=self._uri, params=data
237235
)
238-
return AwsPage(self._version, response, self._solution)
236+
return AwsPage(self._version, response)
239237

240238
def get_page(self, target_url):
241239
"""
@@ -248,7 +246,7 @@ def get_page(self, target_url):
248246
:rtype: twilio.rest.accounts.v1.credential.aws.AwsPage
249247
"""
250248
response = self._version.domain.twilio.request("GET", target_url)
251-
return AwsPage(self._version, response, self._solution)
249+
return AwsPage(self._version, response)
252250

253251
async def get_page_async(self, target_url):
254252
"""
@@ -261,7 +259,7 @@ async def get_page_async(self, target_url):
261259
:rtype: twilio.rest.accounts.v1.credential.aws.AwsPage
262260
"""
263261
response = await self._version.domain.twilio.request_async("GET", target_url)
264-
return AwsPage(self._version, response, self._solution)
262+
return AwsPage(self._version, response)
265263

266264
def get(self, sid):
267265
"""
@@ -335,10 +333,10 @@ def __init__(self, version, payload, sid: Optional[str] = None):
335333
"url": payload.get("url"),
336334
}
337335

338-
self._context = None
339336
self._solution = {
340337
"sid": sid or self._properties["sid"],
341338
}
339+
self._context: Optional[AwsContext] = None
342340

343341
@property
344342
def _proxy(self):

twilio/rest/accounts/v1/credential/public_key.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def __init__(self, version: Version):
3535
"""
3636
super().__init__(version)
3737

38-
# Path Solution
39-
self._solution = {}
40-
self._uri = "/Credentials/PublicKeys".format(**self._solution)
38+
self._uri = "/Credentials/PublicKeys"
4139

4240
def create(self, public_key, friendly_name=values.unset, account_sid=values.unset):
4341
"""
@@ -208,7 +206,7 @@ def page(
208206
)
209207

210208
response = self._version.page(method="GET", uri=self._uri, params=data)
211-
return PublicKeyPage(self._version, response, self._solution)
209+
return PublicKeyPage(self._version, response)
212210

213211
async def page_async(
214212
self, page_token=values.unset, page_number=values.unset, page_size=values.unset
@@ -235,7 +233,7 @@ async def page_async(
235233
response = await self._version.page_async(
236234
method="GET", uri=self._uri, params=data
237235
)
238-
return PublicKeyPage(self._version, response, self._solution)
236+
return PublicKeyPage(self._version, response)
239237

240238
def get_page(self, target_url):
241239
"""
@@ -248,7 +246,7 @@ def get_page(self, target_url):
248246
:rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyPage
249247
"""
250248
response = self._version.domain.twilio.request("GET", target_url)
251-
return PublicKeyPage(self._version, response, self._solution)
249+
return PublicKeyPage(self._version, response)
252250

253251
async def get_page_async(self, target_url):
254252
"""
@@ -261,7 +259,7 @@ async def get_page_async(self, target_url):
261259
:rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyPage
262260
"""
263261
response = await self._version.domain.twilio.request_async("GET", target_url)
264-
return PublicKeyPage(self._version, response, self._solution)
262+
return PublicKeyPage(self._version, response)
265263

266264
def get(self, sid):
267265
"""
@@ -335,10 +333,10 @@ def __init__(self, version, payload, sid: Optional[str] = None):
335333
"url": payload.get("url"),
336334
}
337335

338-
self._context = None
339336
self._solution = {
340337
"sid": sid or self._properties["sid"],
341338
}
339+
self._context: Optional[PublicKeyContext] = None
342340

343341
@property
344342
def _proxy(self):

twilio/rest/accounts/v1/secondary_auth_token.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414

1515

16+
from typing import Optional
1617
from twilio.base import deserialize
1718
from twilio.base import values
1819
from twilio.base.instance_context import InstanceContext
@@ -33,9 +34,6 @@ def __init__(self, version: Version):
3334
"""
3435
super().__init__(version)
3536

36-
# Path Solution
37-
self._solution = {}
38-
3937
def get(self):
4038
"""
4139
Constructs a SecondaryAuthTokenContext
@@ -84,8 +82,8 @@ def __init__(self, version, payload):
8482
"url": payload.get("url"),
8583
}
8684

87-
self._context = None
8885
self._solution = {}
86+
self._context: Optional[SecondaryAuthTokenContext] = None
8987

9088
@property
9189
def _proxy(self):
@@ -205,9 +203,7 @@ def __init__(self, version: Version):
205203
"""
206204
super().__init__(version)
207205

208-
# Path Solution
209-
self._solution = {}
210-
self._uri = "/AuthTokens/Secondary".format(**self._solution)
206+
self._uri = "/AuthTokens/Secondary"
211207

212208
def create(self):
213209
"""
@@ -272,5 +268,5 @@ def __repr__(self):
272268
:returns: Machine friendly representation
273269
:rtype: str
274270
"""
275-
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
276-
return "<Twilio.Accounts.V1.SecondaryAuthTokenContext {}>".format(context)
271+
272+
return "<Twilio.Accounts.V1.SecondaryAuthTokenContext>"

twilio/rest/api/v2010/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Do not edit the class manually.
1313
"""
1414

15+
from typing import Optional
1516
from twilio.base.version import Version
1617
from twilio.base.domain import Domain
1718
from twilio.rest.api.v2010.account import AccountList
@@ -26,8 +27,8 @@ def __init__(self, domain: Domain):
2627
:param domain: The Twilio.api domain
2728
"""
2829
super().__init__(domain, "2010-04-01")
29-
self._accounts = None
30-
self._account = None
30+
self._accounts: Optional[AccountList] = None
31+
self._account: Optional[AccountContext] = None
3132

3233
@property
3334
def accounts(self) -> AccountList:

0 commit comments

Comments
 (0)