Skip to content

Commit 86c7fd9

Browse files
Fix the typing for BroadTryClause.visit_tryexcept
We're calling it from visit_tryfinally it's not strictly the expected for the visitor pattern
1 parent 0a042a8 commit 86c7fd9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pylint/extensions/broad_try_clause.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
1111

1212
"""Looks for try/except statements with too much code in the try clause."""
13+
from typing import Union
1314

1415
from astroid import nodes
1516

@@ -59,7 +60,7 @@ def _count_statements(self, try_node):
5960

6061
return statement_count
6162

62-
def visit_tryexcept(self, node: nodes.TryExcept) -> None:
63+
def visit_tryexcept(self, node: Union[nodes.TryExcept, nodes.TryFinally]) -> None:
6364
try_clause_statements = self._count_statements(node)
6465
if try_clause_statements > self.config.max_try_statements:
6566
msg = f"try clause contains {try_clause_statements} statements, expected at most {self.config.max_try_statements}"

0 commit comments

Comments
 (0)