Method: pylint.utils.pragma_parser.parse_pragma
Calls: 1359, Exceptions: 38, Paths: 9Back
Path 1: 1344 calls (0.99)
'disable=missing-docstring' (64) 'disable=too-few-public-methods' (53) 'disable=invalid-name' (31) 'disable=missing-docstring,too-few-public-methods' ...
PragmaRepresenter (1344) None (1344)
GeneratorExit (25)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)
Path 2: 5 calls (0.0)
'skip-file' (3) 'disable-all' (2)
PragmaRepresenter (5) None (5)
GeneratorExit (4)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)
Path 3: 3 calls (0.0)
'bouboule=1' (1) 'unknown-keyword = missing-docstring' (1) 'unknown-keyword = ' (1)
UnRecognizedOptionError (3)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)
Path 4: 2 calls (0.0)
'disable missing-docstring' (2)
InvalidPragmaError (2)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)
Path 5: 1 calls (0.0)
'disable = missing-docstring, invalid-name, enable = R0202, no-staticmethod-decorator' (1)
PragmaRepresenter (2) None (1)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)
Path 6: 1 calls (0.0)
'= missing-docstring' (1)
InvalidPragmaError (1)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)
Path 7: 1 calls (0.0)
'disable-all = missing-docstring' (1)
UnRecognizedOptionError (1)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)
Path 8: 1 calls (0.0)
'unknown-keyword' (1)
UnRecognizedOptionError (1)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)
Path 9: 1 calls (0.0)
'disable = ' (1)
None (1)
InvalidPragmaError (1)
1def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
2 action: str | None = None
3 messages: list[str] = []
4 assignment_required = False
5 previous_token = ""
6
7 for mo in re.finditer(TOK_REGEX, pylint_pragma):
8 kind = mo.lastgroup
9 value = mo.group()
10
11 if kind == "ASSIGN":
12 if not assignment_required:
13 if action:
14 # A keyword has been found previously but doesn't support assignment
15 raise UnRecognizedOptionError(
16 "The keyword doesn't support assignment", action
17 )
18 if previous_token:
19 # Something found previously but not a known keyword
20 raise UnRecognizedOptionError(
21 "The keyword is unknown", previous_token
22 )
23 # Nothing at all detected before this assignment
24 raise InvalidPragmaError("Missing keyword before assignment", "")
25 assignment_required = False
26 elif assignment_required:
27 raise InvalidPragmaError(
28 "The = sign is missing after the keyword", action or ""
29 )
30 elif kind == "KEYWORD":
31 if action:
32 yield emit_pragma_representer(action, messages)
33 action = value
34 messages = []
35 assignment_required = action in MESSAGE_KEYWORDS
36 elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}:
37 messages.append(value)
38 assignment_required = False
39 else:
40 raise RuntimeError("Token not recognized")
41
42 previous_token = value
43
44 if action:
45 yield emit_pragma_representer(action, messages)
46 else:
47 raise UnRecognizedOptionError("The keyword is unknown", previous_token)