From 887852d7ef02bed6dff5204ace73d8e43a66e32f Mon Sep 17 00:00:00 2001 From: Liora Milbaum Date: Tue, 6 Dec 2022 06:15:22 +0200 Subject: refactor: Moving RETRYABLE_TRANSIENT_ERROR_CODES to const --- gitlab/client.py | 3 +-- gitlab/const.py | 2 ++ tests/unit/test_gitlab_http_methods.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gitlab/client.py b/gitlab/client.py index 8514ffd..5e1db0a 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -22,7 +22,6 @@ REDIRECT_MSG = ( "{source!r} to {target!r}" ) -RETRYABLE_TRANSIENT_ERROR_CODES = [500, 502, 503, 504] + list(range(520, 531)) # https://docs.gitlab.com/ee/api/#offset-based-pagination _PAGINATION_URL = ( @@ -781,7 +780,7 @@ class Gitlab: return result if (429 == result.status_code and obey_rate_limit) or ( - result.status_code in RETRYABLE_TRANSIENT_ERROR_CODES + result.status_code in gitlab.const.RETRYABLE_TRANSIENT_ERROR_CODES and retry_transient_errors ): # Response headers documentation: diff --git a/gitlab/const.py b/gitlab/const.py index 1dab752..5d3602b 100644 --- a/gitlab/const.py +++ b/gitlab/const.py @@ -131,6 +131,8 @@ SEARCH_SCOPE_PROJECT_NOTES = SearchScope.PROJECT_NOTES.value USER_AGENT: str = f"{__title__}/{__version__}" +RETRYABLE_TRANSIENT_ERROR_CODES = [500, 502, 503, 504] + list(range(520, 531)) + __all__ = [ "AccessLevel", "Visibility", diff --git a/tests/unit/test_gitlab_http_methods.py b/tests/unit/test_gitlab_http_methods.py index 252ecb6..d4abe0b 100644 --- a/tests/unit/test_gitlab_http_methods.py +++ b/tests/unit/test_gitlab_http_methods.py @@ -6,7 +6,7 @@ import requests import responses from gitlab import GitlabHttpError, GitlabList, GitlabParsingError, RedirectError -from gitlab.client import RETRYABLE_TRANSIENT_ERROR_CODES +from gitlab.const import RETRYABLE_TRANSIENT_ERROR_CODES from tests.unit import helpers -- cgit v1.2.1