Skip to content

Commit

Permalink
installing built file
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Dec 21, 2024
1 parent d390e7f commit 2435b0a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- name: Build
run: |
python -m build
- name: Install built package
run: |
pip install dist/*.whl
- name: Lint
run: |
make lint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def add_bearer_auth_header(token, headers: Optional[Dict[str, str]] = None) -> D
Args:
token (str): The Bearer token to be added to the headers.
headers (Optional[Dict[str, str]]): An optional dictionary of headers to which the Authorization header will be added.
headers (Optional[Dict[str, str]]): An optional dictionary of headers to which the Authorization header will be added.
If not provided, a new dictionary will be created.
Returns:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
"""Implements a custom Retry class that allows for blacklisting certain status codes that will not retry."""
from urllib3.util.retry import Retry


class BlacklistRetry(Retry):
def __init__(self, status_blacklist=None, **kwargs):
"""
BlacklistRetry class extends the Retry class to include a blacklist of status codes that should not be retried.
"""
def __init__(self, status_blacklist=None, **kwargs) -> None:
self.status_blacklist = status_blacklist
super().__init__(**kwargs)

def is_retry(self, method, status_code, has_retry_after=False):
def is_retry(self, method, status_code, has_retry_after=False) -> bool:
"""
Determines if a request should be retried based on the HTTP method, status code,
and the presence of a 'Retry-After' header.
Args:
method (str): The HTTP method of the request (e.g., 'GET', 'POST').
status_code (int): The HTTP status code of the response.
has_retry_after (bool): Indicates if the response contains a 'Retry-After' header.
Returns:
bool: True if the request should be retried, False otherwise.
"""
if self.status_blacklist is not None and status_code in self.status_blacklist:
return False
else:
Expand Down

0 comments on commit 2435b0a

Please sign in to comment.