Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #79 from sobolevn/patch-4
Browse files Browse the repository at this point in the history
Refactors `hasattr` + `except: pass` to a single `getattr`
  • Loading branch information
terrencepreilly authored Apr 9, 2020
2 parents c3de7bc + e9e1db7 commit a3e19cf
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions darglint/analysis/raise_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,9 @@ def visit_Try(self, node):
if handler.type:
if handler.name and isinstance(handler.type, ast.Name):
self.context.add_variable(handler.name, handler.type)
if hasattr(handler.type, 'id'):
id = getattr(handler.type, 'id')
if id:
self.context.remove_exception(id)
else:
# TODO: What is this? Only in 3.8?
pass
id = getattr(handler.type, 'id', None)
if id:
self.context.remove_exception(id)
else:
self.context.remove_all_exceptions()
for handler in node.handlers:
Expand Down

0 comments on commit a3e19cf

Please sign in to comment.