(1.0.4) pylint fixes
All checks were successful
Actions / build (push) Successful in 21s
Actions / lint (push) Successful in 18s

This commit is contained in:
Seaswimmer 2024-09-17 23:31:50 -04:00
parent 33b63fecc4
commit 7b0b13604b
Signed by: cswimr
GPG key ID: 3813315477F26F82
4 changed files with 8 additions and 10 deletions

View file

@ -1,19 +1,19 @@
class InternalServerError(Exception): class InternalServerError(Exception):
"""Raised when the API returns a 5xx status code"""
def __init__(self, message): def __init__(self, message):
self.message = message self.message = message
super(InternalServerError, self).__init__(message)
class ClientError(Exception): class ClientError(Exception):
"""Raised when the API returns a 4xx status code"""
def __init__(self, message): def __init__(self, message):
self.message = message self.message = message
super(ClientError, self).__init__(message)
class TooManyRequests(Exception): class TooManyRequests(Exception):
"""Raised when the API returns a 429 status code"""
def __init__(self, message): def __init__(self, message):
self.message = message self.message = message
super(TooManyRequests, self).__init__(message)
class RetryLimitExceeded(Exception): class RetryLimitExceeded(Exception):
"""Raised when the retry limit is exceeded"""
def __init__(self, message): def __init__(self, message):
self.message = message self.message = message
super(RetryLimitExceeded, self).__init__(message)

View file

@ -64,12 +64,10 @@ class RestAdapter:
try: try:
if result.status_code == 429: if result.status_code == 429:
raise TooManyRequests(f"{result.message} - {result.data}") raise TooManyRequests(f"{result.message} - {result.data}")
elif 400 <= result.status_code < 500: if 400 <= result.status_code < 500:
raise ClientError(f"{result.status_code} - {result.message} - {result.data}") raise ClientError(f"{result.status_code} - {result.message} - {result.data}")
elif 500 <= result.status_code < 600: if 500 <= result.status_code < 600:
raise InternalServerError(f"{result.status_code} - {result.message} - {result.data}") raise InternalServerError(f"{result.status_code} - {result.message} - {result.data}")
else:
pass
except (TooManyRequests, InternalServerError) as e: except (TooManyRequests, InternalServerError) as e:
if retry_counter < self.config.retry_limit: if retry_counter < self.config.retry_limit:
interval = self.config.interval * retry_counter interval = self.config.interval * retry_counter

View file

@ -1 +1 @@
VERSION = "1.0.3" VERSION = "1.0.4"

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "pyflowery" name = "pyflowery"
version = "1.0.3" version = "1.0.4"
description = "A Python API wrapper for the Flowery API" description = "A Python API wrapper for the Flowery API"
authors = ["cswimr <seaswimmerthefsh@gmail.com>"] authors = ["cswimr <seaswimmerthefsh@gmail.com>"]
license = "GPL 3.0-only" license = "GPL 3.0-only"