Skip to content

Commit 65654dc

Browse files
Type hinting
1 parent 01a37dd commit 65654dc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

inventree/api.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, host=None, **kwargs):
7878
if kwargs.get('connect', True):
7979
self.connect()
8080

81-
def setHostName(self, host):
81+
def setHostName(self, host: str):
8282
"""Validate that the provided base URL is valid"""
8383

8484
if host is None:
@@ -136,7 +136,7 @@ def connect(self):
136136
if not self.token:
137137
self.requestToken()
138138

139-
def constructApiUrl(self, endpoint_url):
139+
def constructApiUrl(self, endpoint_url: str) -> str:
140140
"""Construct an API endpoint URL based on the provided API URL.
141141
142142
Arguments:
@@ -263,14 +263,14 @@ def requestToken(self):
263263

264264
return self.token
265265

266-
def request(self, api_url, **kwargs):
266+
def request(self, url: str, **kwargs):
267267
""" Perform a URL request to the Inventree API """
268268

269269
if not self.connected:
270270
# If we have not established a connection to the server yet, attempt now
271271
self.connect()
272272

273-
api_url = self.constructApiUrl(api_url)
273+
api_url = self.constructApiUrl(url)
274274

275275
data = kwargs.get('data', kwargs.get('json', {}))
276276
files = kwargs.get('files', {})
@@ -391,7 +391,7 @@ def request(self, api_url, **kwargs):
391391

392392
return response
393393

394-
def delete(self, url, **kwargs):
394+
def delete(self, url: str, **kwargs):
395395
""" Perform a DELETE request. Used to remove a record in the database.
396396
397397
"""
@@ -410,7 +410,7 @@ def delete(self, url, **kwargs):
410410

411411
return response
412412

413-
def post(self, url, data, **kwargs):
413+
def post(self, url: str, data: dict, **kwargs):
414414
""" Perform a POST request. Used to create a new record in the database.
415415
416416
Args:
@@ -447,7 +447,7 @@ def post(self, url, data, **kwargs):
447447

448448
return data
449449

450-
def patch(self, url, data, **kwargs):
450+
def patch(self, url: str, data: dict, **kwargs):
451451
"""
452452
Perform a PATCH request.
453453
@@ -485,7 +485,7 @@ def patch(self, url, data, **kwargs):
485485

486486
return data
487487

488-
def put(self, url, data, **kwargs):
488+
def put(self, url: str, data: dict, **kwargs):
489489
"""
490490
Perform a PUT request. Used to update existing records in the database.
491491
@@ -521,7 +521,7 @@ def put(self, url, data, **kwargs):
521521

522522
return data
523523

524-
def get(self, url, **kwargs):
524+
def get(self, url: str, **kwargs):
525525
""" Perform a GET request.
526526
527527
For argument information, refer to the 'request' method

0 commit comments

Comments
 (0)