summaryrefslogtreecommitdiff
path: root/checkers/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'checkers/exceptions.py')
-rw-r--r--checkers/exceptions.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/checkers/exceptions.py b/checkers/exceptions.py
index 84f92ea..c91c95d 100644
--- a/checkers/exceptions.py
+++ b/checkers/exceptions.py
@@ -153,6 +153,8 @@ class ExceptionsChecker(BaseChecker):
except astroid.InferenceError:
pass
else:
+ if cause is YES:
+ return
if isinstance(cause, astroid.Const):
if cause.value is not None:
self.add_message('bad-exception-context',
@@ -237,14 +239,14 @@ class ExceptionsChecker(BaseChecker):
nb_handlers = len(node.handlers)
for index, handler in enumerate(node.handlers):
# single except doing nothing but "pass" without else clause
- if nb_handlers == 1 and is_empty(handler.body) and not node.orelse:
+ if is_empty(handler.body) and not node.orelse:
self.add_message('pointless-except', node=handler.type or handler.body[0])
if handler.type is None:
- if nb_handlers == 1 and not is_raising(handler.body):
+ if not is_raising(handler.body):
self.add_message('bare-except', node=handler)
# check if a "except:" is followed by some other
# except
- elif index < (nb_handlers - 1):
+ if index < (nb_handlers - 1):
msg = 'empty except clause should always appear last'
self.add_message('bad-except-order', node=node, args=msg)
@@ -268,7 +270,7 @@ class ExceptionsChecker(BaseChecker):
self.add_message('bad-except-order', node=handler.type, args=msg)
if (exc.name in self.config.overgeneral_exceptions
and exc.root().name == EXCEPTIONS_MODULE
- and nb_handlers == 1 and not is_raising(handler.body)):
+ and not is_raising(handler.body)):
self.add_message('broad-except', args=exc.name, node=handler.type)
if (not inherit_from_std_ex(exc) and