Skip to content

Commit

Permalink
Does pdm run nox -R, did pyright update or something because it error…
Browse files Browse the repository at this point in the history
…ed on something that it was cool with earlier?

Signed-off-by: Alex Schoenhofen <[email protected]>
  • Loading branch information
alentoghostflame committed Jul 27, 2023
1 parent dea8091 commit 148b326
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions disnake/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,14 @@ def _make_headers(
"""
ret = original_headers.copy()

if "Authorization" not in ret and auth is not None:
ret["Authorization"] = self._default_auth if auth is MISSING else auth
if "Authorization" not in ret:
if auth is None:
pass # We do nothing, this is here to make the logic easier to read.
elif auth is MISSING:
if self._default_auth is not None:
ret["Authorization"] = self._default_auth
else: # auth isn't None or MISSING, so it must be something.
ret["Authorization"] = auth

if "User-Agent" not in ret and self.user_agent:
ret["User-Agent"] = self.user_agent
Expand Down Expand Up @@ -937,10 +943,11 @@ async def request(
async with global_rate_limit:
async with url_rate_limit:
# This check is for asyncio.gather()'d requests where the rate limit can change.
if (
temp := self._get_url_rate_limit(route.method, route, auth)
) not in (url_rate_limit, None):
temp = cast(RateLimit, temp)
if (temp := self._get_url_rate_limit(route.method, route, auth)) not in (
url_rate_limit,
None,
):
# temp = cast(RateLimit, temp)
_log.debug(
"Route %s had the rate limit changed, resetting and retrying.",
rate_limit_path,
Expand Down Expand Up @@ -1062,7 +1069,10 @@ async def request(
await asyncio.sleep(1 + retry_count * 2)
should_retry = True
else:
_log.info("Path %s encountered a Discord server issue.", rate_limit_path)
_log.info(
"Path %s encountered a Discord server issue.",
rate_limit_path,
)
raise DiscordServerError(response, ret)
elif response.status == 401:
_log.warning(
Expand Down Expand Up @@ -1104,8 +1114,12 @@ async def request(
)
should_retry = True
else:
_log.warning("We are being rate limited on path %s.", rate_limit_path)
raise HTTPException(response, ret) # TODO: Make actual HTTPRateLimit error?
_log.warning(
"We are being rate limited on path %s.", rate_limit_path
)
raise HTTPException(
response, ret
) # TODO: Make actual HTTPRateLimit error?

elif response.status >= 500:
raise DiscordServerError(response, ret)
Expand Down

0 comments on commit 148b326

Please sign in to comment.