Method: pylint.extensions.docparams.DocstringParameterChecker.visit_raise
Calls: 110, Exceptions: 3, Paths: 13Back
Path 1: 55 calls (0.5)
Raise (55)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 2: 18 calls (0.16)
Raise (18)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 3: 10 calls (0.09)
Raise (10)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 4: 9 calls (0.08)
Raise (9)
None (9)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 5: 5 calls (0.05)
Raise (5)
None (5)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 6: 3 calls (0.03)
Raise (3)
None (3)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 7: 3 calls (0.03)
Raise (3)
GeneratorExit (3)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 8: 2 calls (0.02)
Raise (2)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 9: 1 calls (0.01)
Raise (1)
None (1)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 10: 1 calls (0.01)
Raise (1)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 11: 1 calls (0.01)
Raise (1)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 12: 1 calls (0.01)
Raise (1)
None (1)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)
Path 13: 1 calls (0.01)
Raise (1)
None (1)
1def visit_raise(self, node: nodes.Raise) -> None:
2 func_node = node.frame(future=True)
3 if not isinstance(func_node, astroid.FunctionDef):
4 return
5
6 # skip functions that match the 'no-docstring-rgx' config option
7 no_docstring_rgx = self.linter.config.no_docstring_rgx
8 if no_docstring_rgx and re.match(no_docstring_rgx, func_node.name):
9 return
10
11 expected_excs = utils.possible_exc_types(node)
12
13 if not expected_excs:
14 return
15
16 if not func_node.doc_node:
17 # If this is a property setter,
18 # the property should have the docstring instead.
19 property_ = utils.get_setters_property(func_node)
20 if property_:
21 func_node = property_
22
23 doc = utils.docstringify(
24 func_node.doc_node, self.linter.config.default_docstring_type
25 )
26
27 if self.linter.config.accept_no_raise_doc and not doc.exceptions():
28 return
29
30 if not doc.matching_sections():
31 if doc.doc:
32 missing = {exc.name for exc in expected_excs}
33 self._add_raise_message(missing, func_node)
34 return
35
36 found_excs_full_names = doc.exceptions()
37
38 # Extract just the class name, e.g. "error" from "re.error"
39 found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names}
40
41 missing_excs = set()
42 for expected in expected_excs:
43 for found_exc in found_excs_class_names:
44 if found_exc == expected.name:
45 break
46 if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
47 break
48 else:
49 missing_excs.add(expected.name)
50
51 self._add_raise_message(missing_excs, func_node)