1- from . import request
2- from . import assembly
3- from . import template
1+ import typing
42
3+ from typing import Optional
4+
5+ from . import assembly , request , template
6+
7+ if typing .TYPE_CHECKING :
8+ from requests import Response
59
610class Transloadit :
711 """
@@ -27,10 +31,10 @@ class Transloadit:
2731
2832 def __init__ (
2933 self ,
30- auth_key ,
31- auth_secret ,
32- service = "https://api2.transloadit.com" ,
33- duration = 300 ,
34+ auth_key : str ,
35+ auth_secret : str ,
36+ service : str = "https://api2.transloadit.com" ,
37+ duration : int = 300 ,
3438 ):
3539 if not service .startswith (("http://" , "https://" )):
3640 service = "https://" + service
@@ -41,14 +45,14 @@ def __init__(
4145 self .duration = duration
4246 self .request = request .Request (self )
4347
44- def new_assembly (self , params = None ):
48+ def new_assembly (self , params : dict = None ) -> assembly . Assembly :
4549 """
4650 Return an instance of <transloadit.assembly.Assembly> which would be used to create
4751 a new assembly.
4852 """
4953 return assembly .Assembly (self , options = params )
5054
51- def get_assembly (self , assembly_id = None , assembly_url = None ):
55+ def get_assembly (self , assembly_id : str = None , assembly_url : str = None ) -> Response :
5256 """
5357 Get the assembly specified by the 'assembly_id' or the 'assembly_url'
5458 Either the assembly_id or the assembly_url must be specified
@@ -65,7 +69,7 @@ def get_assembly(self, assembly_id=None, assembly_url=None):
6569 url = assembly_url if assembly_url else f"/assemblies/{ assembly_id } "
6670 return self .request .get (url )
6771
68- def list_assemblies (self , params = None ):
72+ def list_assemblies (self , params : dict = None ) -> Response :
6973 """
7074 Get the list of assemblies.
7175
@@ -78,7 +82,7 @@ def list_assemblies(self, params=None):
7882 """
7983 return self .request .get ("/assemblies" , params = params )
8084
81- def cancel_assembly (self , assembly_id = None , assembly_url = None ):
85+ def cancel_assembly (self , assembly_id : str = None , assembly_url : str = None ) -> Response :
8286 """
8387 Cancel the assembly specified by the 'assembly_id' or the 'assembly_url'
8488 Either the assembly_id or the assembly_url must be specified
@@ -95,7 +99,7 @@ def cancel_assembly(self, assembly_id=None, assembly_url=None):
9599 url = assembly_url if assembly_url else f"/assemblies/{ assembly_id } "
96100 return self .request .delete (url )
97101
98- def get_template (self , template_id ) :
102+ def get_template (self , template_id : str ) -> Response :
99103 """
100104 Get the template specified by the 'template_id'.
101105
@@ -106,7 +110,7 @@ def get_template(self, template_id):
106110 """
107111 return self .request .get (f"/templates/{ template_id } " )
108112
109- def list_templates (self , params = None ):
113+ def list_templates (self , params : Optional [ dict ] = None ) -> Response :
110114 """
111115 Get the list of templates.
112116
@@ -119,7 +123,7 @@ def list_templates(self, params=None):
119123 """
120124 return self .request .get ("/templates" , params = params )
121125
122- def new_template (self , name , params = None ):
126+ def new_template (self , name : str , params : Optional [ dict ] = None ) -> template . Template :
123127 """
124128 Return an instance of <transloadit.template.Template> which would be used to create
125129 a new template.
@@ -129,7 +133,7 @@ def new_template(self, name, params=None):
129133 """
130134 return template .Template (self , name , options = params )
131135
132- def update_template (self , template_id , data ) :
136+ def update_template (self , template_id : str , data : dict ) -> Response :
133137 """
134138 Update the template specified by the 'template_id'.
135139
@@ -141,7 +145,7 @@ def update_template(self, template_id, data):
141145 """
142146 return self .request .put (f"/templates/{ template_id } " , data = data )
143147
144- def delete_template (self , template_id ) :
148+ def delete_template (self , template_id : str ) -> Response :
145149 """
146150 Delete the template specified by the 'template_id'.
147151
@@ -152,7 +156,7 @@ def delete_template(self, template_id):
152156 """
153157 return self .request .delete (f"/templates/{ template_id } " )
154158
155- def get_bill (self , month , year ) :
159+ def get_bill (self , month : int , year : int ) -> Response :
156160 """
157161 Get the bill for the specified month and year.
158162
0 commit comments