From 4224a046ab18329d37ac3e2f1af119ea985d15d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Thu, 10 Feb 2022 09:13:54 +0100 Subject: [PATCH 1/2] Fix parsing of long lines when ``missing-final-newline`` is enabled --- ChangeLog | 4 ++++ doc/whatsnew/2.13.rst | 4 ++++ pylint/utils/pragma_parser.py | 5 +---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f786a21f93..fa3506e5d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -129,6 +129,10 @@ Release date: TBA Closes #5569 +* Fix parsing of long lines when ``missing-final-newline`` is enabled. + + Closes #5724 + * Fix false positives for ``used-before-assignment`` from using named expressions in a ternary operator test and using that expression as a call argument. diff --git a/doc/whatsnew/2.13.rst b/doc/whatsnew/2.13.rst index 7daac870d0..efa358da14 100644 --- a/doc/whatsnew/2.13.rst +++ b/doc/whatsnew/2.13.rst @@ -180,6 +180,10 @@ Other Changes Closes #5177, #5212 +* Fix parsing of long lines when ``missing-final-newline`` is enabled. + + Closes #5724 + * Fix ``unnecessary_dict_index_lookup`` false positive when deleting a dictionary's entry. Closes #4716 diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py index 5ef4ef481a..d89a085cdb 100644 --- a/pylint/utils/pragma_parser.py +++ b/pylint/utils/pragma_parser.py @@ -9,10 +9,7 @@ # so that an option can be continued with the reasons # why it is active or disabled. OPTION_RGX = r""" - \s* # Any number of whitespace - \#? # One or zero hash - .* # Anything (as much as possible) - (\s* # Beginning of first matched group and any number of whitespaces + ( # Beginning of first matched group and any number of whitespaces \# # Beginning of comment .*? # Anything (as little as possible) \bpylint: # pylint word and column From 591bf38ee9d7788073dd5db0fc7c2402ebec65be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Thu, 10 Feb 2022 09:39:14 +0100 Subject: [PATCH 2/2] Update --- pylint/utils/pragma_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py index d89a085cdb..fb5bf45463 100644 --- a/pylint/utils/pragma_parser.py +++ b/pylint/utils/pragma_parser.py @@ -11,7 +11,7 @@ OPTION_RGX = r""" ( # Beginning of first matched group and any number of whitespaces \# # Beginning of comment - .*? # Anything (as little as possible) + \s*? # Any whitespaces (as little as possible) \bpylint: # pylint word and column \s* # Any number of whitespaces ([^;#\n]+)) # Anything except semicolon or hash or newline (it is the second matched group)