def check_response(method):
 @functools.wraps(method)
 def wrapped(self, *args, **kwargs):
  resp = method(self, *args, **kwargs)
  status = resp.status_code
  if (400 < status):
   if (resp.status_code == 429):
    self.handle_429(resp, *args, **kwargs)
    return method(self, *args, **kwargs).json()
   msg_args = (resp, resp.text, resp.headers)
   msg = ('Bad api response: %r %r %r' % msg_args)
   raise BadApiResponse(resp, msg)
  return resp.json()
 return wrapped

def check_response ( method ) : @ functools . wraps ( method ) def wrapped ( self , * args , ** kwargs ) : resp = method ( self , * args , ** kwargs ) status = resp . status_code if ( 400 < status ) : if ( resp . status_code == 429 ) : self . handle_429 ( resp , * args , ** kwargs ) return method ( self , * args , ** kwargs ) . json ( ) msg_args = ( resp , resp . text , resp . headers ) msg = ( 'Bad api response: %r %r %r' % msg_args ) raise BadApiResponse ( resp , msg ) return resp . json ( ) return wrapped
decorated functions will run .