diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2017-12-11 10:13:41 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2017-12-11 10:13:41 +0100 |
commit | 72ad81884360a9c792ed4fae32e68806e01067b5 (patch) | |
tree | b25aa7823bdf311b97c3ae09594cd3b5e08888d9 | |
parent | ff33b83c2adc0577917117c51ba5e16288c361c5 (diff) | |
download | pylint-git-72ad81884360a9c792ed4fae32e68806e01067b5.tar.gz |
Don't emit catching-non-exception when a tuple component has unknown bases
Close #1756
-rw-r--r-- | pylint/checkers/exceptions.py | 3 | ||||
-rw-r--r-- | pylint/test/functional/invalid_exceptions_caught.py | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py index 0d8c05954..2130a99be 100644 --- a/pylint/checkers/exceptions.py +++ b/pylint/checkers/exceptions.py @@ -305,7 +305,8 @@ class ExceptionsChecker(checkers.BaseChecker): if any(node is astroid.YES for node in inferred): # Don't emit if we don't know every component. return - if all(node and utils.inherit_from_std_ex(node) + if all(node and (utils.inherit_from_std_ex(node) or + not utils.has_known_bases(node)) for node in inferred): return diff --git a/pylint/test/functional/invalid_exceptions_caught.py b/pylint/test/functional/invalid_exceptions_caught.py index 2d87239e6..2b1dbacd8 100644 --- a/pylint/test/functional/invalid_exceptions_caught.py +++ b/pylint/test/functional/invalid_exceptions_caught.py @@ -121,3 +121,15 @@ try: raise Second except Second: pass + + +class SomeBase(UnknownError): + pass + + +EXCEPTIONS = (SomeBase, ValueError) + +try: + raise ValueError +except EXCEPTIONS: + pass |