Skip to content

Commit

Permalink
Add support for py-version for checker continue-in-finally.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbyrnepr2 committed Jun 24, 2022
1 parent 6e58d79 commit e699060
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pylint/checkers/base/basic_error_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class BasicErrorChecker(_BasicChecker):
"continue-in-finally",
"Emitted when the `continue` keyword is found "
"inside a finally clause, which is a SyntaxError.",
{"maxversion": (3, 8)},
),
"E0117": (
"nonlocal name %s found without binding",
Expand All @@ -206,6 +205,10 @@ class BasicErrorChecker(_BasicChecker):
),
}

def open(self) -> None:
py_version = self.linter.config.py_version
self._py38_plus = py_version >= (3, 8)

@utils.only_required_for_messages("function-redefined")
def visit_classdef(self, node: nodes.ClassDef) -> None:
self._check_redefinition("class", node)
Expand Down Expand Up @@ -490,6 +493,7 @@ def _check_in_loop(self, node, node_name):
isinstance(parent, nodes.TryFinally)
and node in parent.finalbody
and isinstance(node, nodes.Continue)
and not self._py38_plus
):
self.add_message("continue-in-finally", node=node)

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/c/continue_in_finally.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[testoptions]
max_pyver=3.8
[main]
py-version=3.7

0 comments on commit e699060

Please sign in to comment.