From 119c5a0618c82b7f425a59e2e6a8c5ce35c48a37 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 22 Jun 2018 14:47:56 +0200 Subject: [PATCH] [lint] Remove unused variables Left over from various refactoring and rewrites. --- discord/abc.py | 2 +- discord/client.py | 2 +- discord/ext/commands/core.py | 2 +- discord/shard.py | 6 +++--- discord/state.py | 4 ++-- discord/utils.py | 2 +- discord/voice_client.py | 1 - 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/discord/abc.py b/discord/abc.py index 608670493..002980a4e 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -955,7 +955,7 @@ class Connectable(metaclass=abc.ABCMeta): :class:`VoiceClient` A voice client that is fully connected to the voice server. """ - key_id, key_name = self._get_voice_client_key() + key_id, _ = self._get_voice_client_key() state = self._state if state._get_voice_client(key_id): diff --git a/discord/client.py b/discord/client.py index 9c1fdac25..440b5be32 100644 --- a/discord/client.py +++ b/discord/client.py @@ -367,7 +367,7 @@ class Client: while True: try: await self.ws.poll_event() - except ResumeWebSocket as e: + except ResumeWebSocket: log.info('Got a request to RESUME the websocket.') coro = DiscordWebSocket.from_client(self, shard_id=self.shard_id, session=self.ws.session_id, diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index b79f5b97c..56c4baff4 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -321,7 +321,7 @@ class Command: try: # first/second parameter is context result.popitem(last=False) - except Exception as e: + except Exception: raise ValueError('Missing context parameter') from None return result diff --git a/discord/shard.py b/discord/shard.py index 8e04b9c5b..c06e6398f 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -74,7 +74,7 @@ class Shard: async def poll(self): try: await self.ws.poll_event() - except ResumeWebSocket as e: + except ResumeWebSocket: log.info('Got a request to RESUME the websocket at Shard ID %s.', self.id) coro = DiscordWebSocket.from_client(self._client, resume=True, shard_id=self.id, @@ -212,7 +212,7 @@ class AutoShardedClient(Client): try: coro = websockets.connect(gateway, loop=self.loop, klass=DiscordWebSocket, compression=None) ws = await asyncio.wait_for(coro, loop=self.loop, timeout=180.0) - except Exception as e: + except Exception: log.info('Failed to connect for shard_id: %s. Retrying...', shard_id) await asyncio.sleep(5.0, loop=self.loop) return (await self.launch_shard(gateway, shard_id)) @@ -265,7 +265,7 @@ class AutoShardedClient(Client): while True: pollers = [shard.get_future() for shard in self.shards.values()] - done, pending = await asyncio.wait(pollers, loop=self.loop, return_when=asyncio.FIRST_COMPLETED) + done, _ = await asyncio.wait(pollers, loop=self.loop, return_when=asyncio.FIRST_COMPLETED) for f in done: # we wanna re-raise to the main Client.connect handler if applicable f.result() diff --git a/discord/state.py b/discord/state.py index 779a4a9d1..f02755322 100644 --- a/discord/state.py +++ b/discord/state.py @@ -240,7 +240,7 @@ class ConnectionState: return guild def chunks_needed(self, guild): - for chunk in range(math.ceil(guild._member_count / 1000)): + for _ in range(math.ceil(guild._member_count / 1000)): yield self.receive_chunk(guild.id) def _get_guild_channel(self, data): @@ -423,7 +423,7 @@ class ConnectionState: emoji = self._upgrade_partial_emoji(emoji) try: reaction = message._remove_reaction(data, emoji, raw.user_id) - except (AttributeError, ValueError) as e: # eventual consistency lol + except (AttributeError, ValueError): # eventual consistency lol pass else: user = self._get_reaction_user(message.channel, raw.user_id) diff --git a/discord/utils.py b/discord/utils.py index 5c939922e..b4a79d677 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -281,7 +281,7 @@ async def async_all(gen, *, check=_isawaitable): return True async def sane_wait_for(futures, *, timeout, loop): - done, pending = await asyncio.wait(futures, timeout=timeout, loop=loop) + _, pending = await asyncio.wait(futures, timeout=timeout, loop=loop) if len(pending) != 0: raise asyncio.TimeoutError() diff --git a/discord/voice_client.py b/discord/voice_client.py index 6f88856ea..f92cc24ed 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -132,7 +132,6 @@ class VoiceClient: async def start_handshake(self): log.info('Starting voice handshake...') - key_id, key_name = self.channel._get_voice_client_key() guild_id, channel_id = self.channel._get_voice_state_pair() state = self._state self.main_ws = ws = state._get_websocket(guild_id)