Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GithubRetry DEFAULT_ALLOWED_METHODS and DEFAULT_STATUS_FORCELIST #2970

Open
jodelasur opened this issue May 14, 2024 · 1 comment

Comments

@jodelasur
Copy link
Contributor

jodelasur commented May 14, 2024

GithubRetry's default values for status_forcelist and allowed_methods are computed in __init__. See here. We had a use case where we wanted extend (not override) the default values, but we resorted to copy-pasting. It would be better to have class members for it, similar to Retry.DEFAULT_ALLOWED_METHODS.

Instead of:

GithubRetry(
    # GithubRetry default value + 401
    status_forcelist=list(range(500, 600)) + [403, 401],
    # GithubRetry default value + "PATCH". 
    # GithubRetry.DEFAULT_ALLOWED_METHODS currently inherited from urllib3.Retry
    allowed_methods=GithubRetry.DEFAULT_ALLOWED_METHODS.union(
        {"GET", "POST", "PATCH"}
    ),
)

it would be better to have:

GithubRetry(
    status_forcelist=GithubRetry.DEFAULT_STATUS_FORCELIST + [401],
    allowed_methods=GithubRetry.DEFAULT_ALLOWED_METHODS | {"PATCH"},
)
@EnricoMi
Copy link
Collaborator

This sounds useful, please go ahead and create a pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants