Repository navigation
Conversation
python-backoff provides the same backoff module but fixes the asyncio.iscoroutinefunction DeprecationWarning on Python 3.14/3.15.
Async requests omitted the User-Agent header entirely. Also label the sync session request as the requests client rather than aiohttp.
The sync request retries via backoff but the async request did not. Apply the same backoff.on_exception to _opencage_async_request, retrying on UnknownError, aiohttp.ClientError and asyncio.TimeoutError. NotAuthorized, Forbidden, RateLimitExceeded and SSLError remain terminal, as on the sync path.
sbscully
commented
Nov 28, 2026
Build the async retry exception tuple so importing opencage.geocoder works when aiohttp is absent, which the import guard intends to support but the decorator previously broke. Add session-based sync and async User-Agent tests, and cover the UnknownError and asyncio.TimeoutError retry branches alongside the existing client-error case.
backoff's default on_backoff/on_giveup handlers log the exception, which embeds the request URL including key=... . Set logger=None on both the sync and async decorators so those lines are not emitted; raised errors stay sanitized via _sanetize_exception_message. Add tests asserting the key never reaches the logs.
Cover NotAuthorizedError, ForbiddenError, RateLimitExceededError and SSLError by asserting the request is attempted exactly once, so a broadened retry tuple would be caught.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the unmaintained backoff package with the maintained python-backoff fork, which removes the asyncio.iscoroutinefunction DeprecationWarning on Python 3.14/3.15.
Retry async requests on transient failures (UnknownError, aiohttp.ClientError, asyncio.TimeoutError), matching the retries the sync path already performs.
Send the OpenCage User-Agent on async requests, which previously sent none. Also correct the sync request's User-Agent, which was labelled as the aiohttp client even though it is made with requests.
Disable backoff retry logging on both paths, since its default handlers log the exception text, which embeds the request URL including the API key.