Skip to content

Commit

Permalink
possible_exc_types checks for Uninferables
Browse files Browse the repository at this point in the history
Fixes #998
  • Loading branch information
AWhetter committed Jul 13, 2016
1 parent 952bb53 commit caa8935
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pylint/extensions/_check_docs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def possible_exc_types(node):
handler = handler.parent

if handler and handler.type:
excs = (exc.name for exc in astroid.unpack_infer(handler.type))
excs = astroid.unpack_infer(handler.type)
excs = (exc.name for exc in excs if exc is not astroid.Uninferable)

excs = set(exc for exc in excs if not node_ignores_exception(node, exc))
return excs
Expand Down
13 changes: 13 additions & 0 deletions pylint/test/extensions/test_check_docs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,18 @@ def my_func():
expected = set(["RuntimeError", "ValueError"])
self.assertEqual(found, expected)

def test_ignores_uninferable_type(self):
raise_node = astroid.extract_node('''
import not_a_module
def my_func():
try:
fake_func()
except not_a_module.Error:
raise #@
''')
found = utils.possible_exc_types(raise_node)
expected = set()
self.assertEqual(found, expected)

if __name__ == '__main__':
unittest.main()

0 comments on commit caa8935

Please sign in to comment.