CommaApi: use context manager for response handling (#34118)

use context manager for response handling
pull/34162/head
Dean Lee 5 months ago committed by GitHub
parent fe24462949
commit e19ecbf75c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      tools/lib/api.py

@ -10,7 +10,7 @@ class CommaApi:
self.session.headers['Authorization'] = 'JWT ' + token
def request(self, method, endpoint, **kwargs):
resp = self.session.request(method, API_HOST + '/' + endpoint, **kwargs)
with self.session.request(method, API_HOST + '/' + endpoint, **kwargs) as resp:
resp_json = resp.json()
if isinstance(resp_json, dict) and resp_json.get('error'):
if resp.status_code in [401, 403]:

Loading…
Cancel
Save