aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHornwitser <[email protected]>2018-06-22 15:12:56 +0200
committerRapptz <[email protected]>2018-11-24 22:17:57 -0500
commita71b3b5fa0a814c1610b2c685ca8bcbbb233e52a (patch)
tree6e99e481ae99f632f89e906eaffbdb854bb13715
parentRevert "Rework documentation to not duplicate inherited members." (diff)
downloaddiscord.py-a71b3b5fa0a814c1610b2c685ca8bcbbb233e52a.tar.xz
discord.py-a71b3b5fa0a814c1610b2c685ca8bcbbb233e52a.zip
[lint] Limit unneccessarily broad except clauses
Add exception qualifier(s) to bare except clauses swallowing exceptions.
-rw-r--r--discord/abc.py8
-rw-r--r--discord/client.py6
-rw-r--r--discord/context_managers.py2
-rw-r--r--discord/errors.py2
-rw-r--r--discord/ext/commands/bot.py6
-rw-r--r--discord/ext/commands/core.py2
-rw-r--r--discord/gateway.py2
-rw-r--r--discord/message.py4
-rw-r--r--discord/player.py2
-rw-r--r--discord/shard.py2
-rw-r--r--discord/voice_client.py2
11 files changed, 19 insertions, 19 deletions
diff --git a/discord/abc.py b/discord/abc.py
index 02dc765f..d85534f9 100644
--- a/discord/abc.py
+++ b/discord/abc.py
@@ -32,7 +32,7 @@ from collections import namedtuple
from .iterators import HistoryIterator
from .context_managers import Typing
-from .errors import InvalidArgument, ClientException
+from .errors import InvalidArgument, ClientException, HTTPException
from .permissions import PermissionOverwrite, Permissions
from .role import Role
from .invite import Invite
@@ -578,7 +578,7 @@ class GuildChannel:
raise InvalidArgument('No overwrite provided.')
try:
overwrite = PermissionOverwrite(**permissions)
- except:
+ except (ValueError, TypeError):
raise InvalidArgument('Invalid permissions given to keyword arguments.')
else:
if len(permissions) > 0:
@@ -778,7 +778,7 @@ class Messageable(metaclass=abc.ABCMeta):
await asyncio.sleep(delete_after, loop=state.loop)
try:
await ret.delete()
- except:
+ except HTTPException:
pass
asyncio.ensure_future(delete(), loop=state.loop)
return ret
@@ -981,7 +981,7 @@ class Connectable(metaclass=abc.ABCMeta):
except asyncio.TimeoutError as e:
try:
await voice.disconnect(force=True)
- except:
+ except Exception:
# we don't care if disconnect failed because connection failed
pass
raise e # re-raise
diff --git a/discord/client.py b/discord/client.py
index 23907574..6251e65e 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -444,7 +444,7 @@ class Client:
for voice in self.voice_clients:
try:
await voice.disconnect()
- except:
+ except Exception:
# if an error happens during disconnects, disregard it.
pass
@@ -489,7 +489,7 @@ class Client:
def _silence_gathered(fut):
try:
fut.result()
- except:
+ except Exception:
pass
finally:
loop.stop()
@@ -516,7 +516,7 @@ class Client:
try:
return task.result() # suppress unused task warning
- except:
+ except Exception:
return None
def run(self, *args, **kwargs):
diff --git a/discord/context_managers.py b/discord/context_managers.py
index 101bea6e..9297286f 100644
--- a/discord/context_managers.py
+++ b/discord/context_managers.py
@@ -30,7 +30,7 @@ def _typing_done_callback(fut):
# just retrieve any exception and call it a day
try:
fut.exception()
- except:
+ except Exception:
pass
class Typing:
diff --git a/discord/errors.py b/discord/errors.py
index 3111675a..004620d3 100644
--- a/discord/errors.py
+++ b/discord/errors.py
@@ -58,7 +58,7 @@ def flatten_error_dict(d, key=''):
if isinstance(v, dict):
try:
_errors = v['_errors']
- except Exception:
+ except KeyError:
items.extend(flatten_error_dict(v, new_key).items())
else:
items.append((new_key, ' '.join(x.get('message', '') for x in _errors)))
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py
index c9ce299e..04a5452f 100644
--- a/discord/ext/commands/bot.py
+++ b/discord/ext/commands/bot.py
@@ -195,13 +195,13 @@ class BotBase(GroupMixin):
for extension in tuple(self.extensions):
try:
self.unload_extension(extension)
- except:
+ except Exception:
pass
for cog in tuple(self.cogs):
try:
self.remove_cog(cog)
- except:
+ except Exception:
pass
await super().close()
@@ -759,7 +759,7 @@ class BotBase(GroupMixin):
else:
try:
func(self)
- except:
+ except Exception:
pass
finally:
# finally remove the import..
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 0aa79645..bcf2cd8a 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -240,7 +240,7 @@ class Command:
try:
module = converter.__module__
- except:
+ except AttributeError:
pass
else:
if module.startswith('discord.') and not module.endswith('converter'):
diff --git a/discord/gateway.py b/discord/gateway.py
index 23b5de77..7e04018a 100644
--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -76,7 +76,7 @@ class KeepAliveHandler(threading.Thread):
try:
f.result()
- except:
+ except Exception:
pass
finally:
self.stop()
diff --git a/discord/message.py b/discord/message.py
index 00c5ef73..35d7626e 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -32,7 +32,7 @@ from .reaction import Reaction
from .emoji import Emoji, PartialEmoji
from .calls import CallMessage
from .enums import MessageType, try_enum
-from .errors import InvalidArgument, ClientException
+from .errors import InvalidArgument, ClientException, HTTPException
from .embeds import Embed
class Attachment:
@@ -599,7 +599,7 @@ class Message:
await asyncio.sleep(delete_after, loop=self._state.loop)
try:
await self._state.http.delete_message(self.channel.id, self.id)
- except:
+ except HTTPException:
pass
asyncio.ensure_future(delete(), loop=self._state.loop)
diff --git a/discord/player.py b/discord/player.py
index c645ae66..a31b8fd2 100644
--- a/discord/player.py
+++ b/discord/player.py
@@ -303,7 +303,7 @@ class AudioPlayer(threading.Thread):
if self.after is not None:
try:
self.after(self._current_error)
- except:
+ except Exception:
log.exception('Calling the after function failed.')
def stop(self):
diff --git a/discord/shard.py b/discord/shard.py
index 1f73b0de..dfa255f5 100644
--- a/discord/shard.py
+++ b/discord/shard.py
@@ -282,7 +282,7 @@ class AutoShardedClient(Client):
for vc in self.voice_clients:
try:
await vc.disconnect()
- except:
+ except Exception:
pass
to_close = [shard.ws.close() for shard in self.shards.values()]
diff --git a/discord/voice_client.py b/discord/voice_client.py
index 7479031e..b519b981 100644
--- a/discord/voice_client.py
+++ b/discord/voice_client.py
@@ -177,7 +177,7 @@ class VoiceClient:
if self.socket:
try:
self.socket.close()
- except:
+ except Exception:
pass
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)