Ejemplo n.º 1
0
    def _check_if_needs_except(self, node: ast.Try) -> None:
        if not node.finalbody or node.handlers:
            return

        context = nodes.get_context(node)
        if isinstance(context, FunctionNodes) and context.decorator_list:
            # This is used inside a decorated function, it might be the only
            # way to handle this situation. Eg: ``@contextmanager``
            return

        self.add_violation(UselessFinallyViolation(node))
Ejemplo n.º 2
0
 def _check_if_needs_except(self, node: ast.Try) -> None:
     if node.finalbody and not node.handlers:
         self.add_violation(UselessFinallyViolation(node))