diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/test/functional/control_pragmas.py | 19 | ||||
-rw-r--r-- | pylint/test/functional/control_pragmas.txt | 0 | ||||
-rw-r--r-- | pylint/utils.py | 4 |
4 files changed, 25 insertions, 2 deletions
@@ -7,6 +7,10 @@ What's New in Pylint 2.2? Release date: TBA + * ``pylint`` is less eager to consume the whole line for pragmas + + Close #2485 + * Change ``unbalanced-tuple-unpacking`` back to a warning. It used to be a warning until a couple of years ago, after it was promoted to diff --git a/pylint/test/functional/control_pragmas.py b/pylint/test/functional/control_pragmas.py new file mode 100644 index 000000000..993f9a5dd --- /dev/null +++ b/pylint/test/functional/control_pragmas.py @@ -0,0 +1,19 @@ +# pylint: disable=missing-docstring + + +def test_pragma(): + """Test that the control pragmas are not too eager to consume the entire line + + We should stop either at: + - ; or # + - or at the end of line + """ + # noqa: E501 # pylint: disable=unused-variable #nosec + variable = 1 + + # noqa # pylint: disable=undefined-variable,no-member; don't trigger + other_variable = some_variable + variable.member + + # noqa # pylint: disable=unbalanced-tuple-unpacking,no-member # no trigger + first, second = some_other_variable + return first + other_variable.method() diff --git a/pylint/test/functional/control_pragmas.txt b/pylint/test/functional/control_pragmas.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/pylint/test/functional/control_pragmas.txt diff --git a/pylint/utils.py b/pylint/utils.py index fb7075c9c..76afdea09 100644 --- a/pylint/utils.py +++ b/pylint/utils.py @@ -78,10 +78,10 @@ MSG_STATE_SCOPE_CONFIG = 0 MSG_STATE_SCOPE_MODULE = 1 MSG_STATE_CONFIDENCE = 2 -# Allow stopping after the first semicolon encountered, +# Allow stopping after the first semicolon/hash encountered, # so that an option can be continued with the reasons # why it is active or disabled. -OPTION_RGX = re.compile(r"\s*#.*\bpylint:\s*([^;]+);{0,1}") +OPTION_RGX = re.compile(r"\s*#.*\bpylint:\s*([^;#]+)[;#]{0,1}") # The line/node distinction does not apply to fatal errors and reports. _SCOPE_EXEMPT = "FR" |