Skip to content

Commit a689344

Browse files
committed
Add support for py-version for checker continue-in-finally.
1 parent 6e58d79 commit a689344

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

pylint/checkers/base/basic_error_checker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ class BasicErrorChecker(_BasicChecker):
189189
"continue-in-finally",
190190
"Emitted when the `continue` keyword is found "
191191
"inside a finally clause, which is a SyntaxError.",
192-
{"maxversion": (3, 8)},
193192
),
194193
"E0117": (
195194
"nonlocal name %s found without binding",
@@ -206,6 +205,10 @@ class BasicErrorChecker(_BasicChecker):
206205
),
207206
}
208207

208+
def open(self) -> None:
209+
py_version = self.linter.config.py_version
210+
self._py38_plus = py_version >= (3, 8)
211+
209212
@utils.only_required_for_messages("function-redefined")
210213
def visit_classdef(self, node: nodes.ClassDef) -> None:
211214
self._check_redefinition("class", node)
@@ -490,6 +493,7 @@ def _check_in_loop(self, node, node_name):
490493
isinstance(parent, nodes.TryFinally)
491494
and node in parent.finalbody
492495
and isinstance(node, nodes.Continue)
496+
and not self._py38_plus
493497
):
494498
self.add_message("continue-in-finally", node=node)
495499

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
[testoptions]
2-
max_pyver=3.8
1+
[main]
2+
py-version=3.7
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
continue-in-finally:9:::'continue' not supported inside 'finally' clause
1+
continue-in-finally:9:8:9:16::'continue' not supported inside 'finally' clause:UNDEFINED

0 commit comments

Comments
 (0)