Skip to content

Commit

Permalink
style: revert Client.connect typeddict changes now that pyright inf…
Browse files Browse the repository at this point in the history
…ers `TypedDict.update` properly
  • Loading branch information
shiftinv committed Nov 15, 2023
1 parent fbc4f8d commit bf7d311
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions disnake/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,14 +1123,12 @@ async def connect(
_log.info("Got a request to %s the websocket.", e.op)
self.dispatch("disconnect")
ws_params.update(
{
"sequence": self.ws.sequence,
"resume": e.resume,
"session": self.ws.session_id,
# use current (possibly new) gateway if resuming,
# reset to default if not
"gateway": self.ws.resume_gateway if e.resume else initial_gateway,
}
sequence=self.ws.sequence,
resume=e.resume,
session=self.ws.session_id,
# use current (possibly new) gateway if resuming,
# reset to default if not
gateway=self.ws.resume_gateway if e.resume else initial_gateway,
)
continue

Expand All @@ -1156,13 +1154,11 @@ async def connect(
# If we get connection reset by peer then try to RESUME
if isinstance(exc, OSError) and exc.errno == ECONNRESET:
ws_params.update(
{
"sequence": self.ws.sequence,
"initial": False,
"resume": True,
"session": self.ws.session_id,
"gateway": self.ws.resume_gateway,
}
sequence=self.ws.sequence,
initial=False,
resume=True,
session=self.ws.session_id,
gateway=self.ws.resume_gateway,
)
continue

Expand All @@ -1185,22 +1181,18 @@ async def connect(
# Always identify back to the initial gateway if we failed while connecting.
# This is in case we fail to connect to the resume_gateway instance.
ws_params.update(
{
"resume": False,
"gateway": initial_gateway,
}
resume=False,
gateway=initial_gateway,
)
else:
# Just try to resume the session.
# If it's not RESUME-able then the gateway will invalidate the session.
# This is apparently what the official Discord client does.
ws_params.update(
{
"sequence": self.ws.sequence,
"resume": True,
"session": self.ws.session_id,
"gateway": self.ws.resume_gateway,
}
sequence=self.ws.sequence,
resume=True,
session=self.ws.session_id,
gateway=self.ws.resume_gateway,
)

async def close(self) -> None:
Expand Down

0 comments on commit bf7d311

Please sign in to comment.