summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-12-20 15:36:02 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-12-20 22:52:51 +0100
commit86c7fd95b7a85b6eb6de4d0eb9b885ee620496bf (patch)
tree99dbd2893f29855f3041d28477694ae148ba53b8
parent0a042a8a42b7ade556b4eaf028bb2bc073227918 (diff)
downloadpylint-git-86c7fd95b7a85b6eb6de4d0eb9b885ee620496bf.tar.gz
Fix the typing for BroadTryClause.visit_tryexcept
We're calling it from visit_tryfinally it's not strictly the expected for the visitor pattern
-rw-r--r--pylint/extensions/broad_try_clause.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/pylint/extensions/broad_try_clause.py b/pylint/extensions/broad_try_clause.py
index 4ccdf258d..b460850c2 100644
--- a/pylint/extensions/broad_try_clause.py
+++ b/pylint/extensions/broad_try_clause.py
@@ -10,6 +10,7 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
"""Looks for try/except statements with too much code in the try clause."""
+from typing import Union
from astroid import nodes
@@ -59,7 +60,7 @@ class BroadTryClauseChecker(checkers.BaseChecker):
return statement_count
- def visit_tryexcept(self, node: nodes.TryExcept) -> None:
+ def visit_tryexcept(self, node: Union[nodes.TryExcept, nodes.TryFinally]) -> None:
try_clause_statements = self._count_statements(node)
if try_clause_statements > self.config.max_try_statements:
msg = f"try clause contains {try_clause_statements} statements, expected at most {self.config.max_try_statements}"