summaryrefslogtreecommitdiff
path: root/pylint/utils/pragma_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/utils/pragma_parser.py')
-rw-r--r--pylint/utils/pragma_parser.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py
index 0bf25de7c..e09cba7c9 100644
--- a/pylint/utils/pragma_parser.py
+++ b/pylint/utils/pragma_parser.py
@@ -9,17 +9,18 @@ from typing import Generator, List, Optional
# 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 comment
- .*? # Anything (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)
- # and end of the first matched group
- [;#]{0,1}""" # From 0 to 1 repetition of semicolon or hash
+ (?:^\s*\#.*|\s*| # Comment line, or whitespaces,
+ \s*\#.*(?=\#.*?\bpylint:)) # or a beginning of an inline comment
+ # followed by "pylint:" pragma
+ (\# # Beginning of comment
+ .*? # Anything (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)
+ # and end of the first matched group
+ [;#]{0,1} # From 0 to 1 repetition of semicolon or hash
+"""
OPTION_PO = re.compile(OPTION_RGX, re.VERBOSE)