Skip to content

Commit

Permalink
Change: Rename attempts to request_attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
n-thumann committed Dec 5, 2024
1 parent 7bbe856 commit 47233f9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions pontos/nvd/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def __init__(
token: Optional[str] = None,
timeout: Optional[Timeout] = DEFAULT_TIMEOUT_CONFIG,
rate_limit: bool = True,
attempts: int = 1,
request_attempts: int = 1,
) -> None:
"""
Create a new instance of the CVE API.
Expand All @@ -354,7 +354,7 @@ def __init__(
rolling 30 second window.
See https://nvd.nist.gov/developers/start-here#divRateLimits
Default: True.
attempts: The number of attempts per HTTP request. Defaults to 1.
request_attempts: The number of attempts per HTTP request. Defaults to 1.
"""
self._url = url
self._token = token
Expand All @@ -368,7 +368,7 @@ def __init__(
self._request_count = 0
self._last_sleep = time.monotonic()

self._attempts = attempts
self._request_attempts = request_attempts

def _request_headers(self) -> Headers:
"""
Expand Down Expand Up @@ -409,9 +409,9 @@ async def _get(
"""
headers = self._request_headers()

for retry in range(self._attempts):
if retry > 0:
delay = RETRY_DELAY**retry
for attempt in range(self._request_attempts):
if attempt > 0:
delay = RETRY_DELAY**attempt
await asyncio.sleep(delay)

Check warning on line 415 in pontos/nvd/api.py

View check run for this annotation

Codecov / codecov/patch

pontos/nvd/api.py#L414-L415

Added lines #L414 - L415 were not covered by tests

await self._consider_rate_limit()
Expand Down
6 changes: 3 additions & 3 deletions pontos/nvd/cpe/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
token: Optional[str] = None,
timeout: Optional[Timeout] = DEFAULT_TIMEOUT_CONFIG,
rate_limit: bool = True,
attempts: int = 1,
request_attempts: int = 1,
) -> None:
"""
Create a new instance of the CPE API.
Expand All @@ -76,14 +76,14 @@ def __init__(
rolling 30 second window.
See https://nvd.nist.gov/developers/start-here#divRateLimits
Default: True.
attempts: The number of attempts per HTTP request. Defaults to 1.
request_attempts: The number of attempts per HTTP request. Defaults to 1.
"""
super().__init__(
DEFAULT_NIST_NVD_CPES_URL,
token=token,
timeout=timeout,
rate_limit=rate_limit,
attempts=attempts,
request_attempts=request_attempts,
)

async def cpe(self, cpe_name_id: Union[str, UUID]) -> CPE:
Expand Down
6 changes: 3 additions & 3 deletions pontos/nvd/cve/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
token: Optional[str] = None,
timeout: Optional[Timeout] = DEFAULT_TIMEOUT_CONFIG,
rate_limit: bool = True,
attempts: int = 1,
request_attempts: int = 1,
) -> None:
"""
Create a new instance of the CVE API.
Expand All @@ -80,14 +80,14 @@ def __init__(
rolling 30 second window.
See https://nvd.nist.gov/developers/start-here#divRateLimits
Default: True.
attempts: The number of attempts per HTTP request. Defaults to 1.
request_attempts: The number of attempts per HTTP request. Defaults to 1.
"""
super().__init__(
DEFAULT_NIST_NVD_CVES_URL,
token=token,
timeout=timeout,
rate_limit=rate_limit,
attempts=attempts,
request_attempts=request_attempts,
)

def cves(
Expand Down
6 changes: 3 additions & 3 deletions pontos/nvd/cve_changes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(
token: Optional[str] = None,
timeout: Optional[Timeout] = DEFAULT_TIMEOUT_CONFIG,
rate_limit: bool = True,
attempts: int = 1,
request_attempts: int = 1,
) -> None:
"""
Create a new instance of the CVE Change History API.
Expand All @@ -70,14 +70,14 @@ def __init__(
rolling 30 second window.
See https://nvd.nist.gov/developers/start-here#divRateLimits
Default: True.
attempts: The number of attempts per HTTP request. Defaults to 1.
request_attempts: The number of attempts per HTTP request. Defaults to 1.
"""
super().__init__(
DEFAULT_NIST_NVD_CVE_HISTORY_URL,
token=token,
timeout=timeout,
rate_limit=rate_limit,
attempts=attempts,
request_attempts=request_attempts,
)

def changes(
Expand Down

0 comments on commit 47233f9

Please sign in to comment.