From 81c886d6b140b5ae8ddbcdba0ff428d95492f333 Mon Sep 17 00:00:00 2001 From: "Dr.Blank" <64108942+Dr-Blank@users.noreply.github.com> Date: Wed, 1 Nov 2023 19:25:33 -0400 Subject: [PATCH] Use Enums for status codes (#5) --- lrclib/api.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lrclib/api.py b/lrclib/api.py index 2953c56..a84d8c5 100644 --- a/lrclib/api.py +++ b/lrclib/api.py @@ -2,6 +2,7 @@ import os import warnings +from http import HTTPStatus from typing import Any, Dict, Optional import requests @@ -61,11 +62,11 @@ def _make_request( response.raise_for_status() except requests.exceptions.HTTPError as exc: response = exc.response # type: ignore - if response.status_code == 404: + if response.status_code == HTTPStatus.NOT_FOUND: raise NotFoundError(response) from exc - if response.status_code == 429: + if response.status_code == HTTPStatus.TOO_MANY_REQUESTS: raise RateLimitError(response) from exc - if response.status_code == 400: + if response.status_code == HTTPStatus.BAD_REQUEST: raise IncorrectPublishTokenError(response) from exc if 500 <= response.status_code < 600: raise ServerError(response) from exc