Path 1: 240 calls (0.2)

['"""\n', ' Pylint score: -1.67\n', '"""\n', '# pylint: disable=broad-except\n', '\n', 'def loop():\n', ' """Run a loop."""\n', ' count = 0\...

True (240)

True (240)

True (240)

True (240)

_MessageStateHandler._is_one_message_enabled def (240)

list (240)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 2: 234 calls (0.2)

['""""\n', ' pylint score: +7.50\n', '"""\n', '\n', 'import os\n', '\n', 'def func():\n', " path = '/tmp'\n", ' os.path.exists(path)\n'] (20...

True (234)

True (234)

True (234)

True (234)

_MessageStateHandler._is_one_message_enabled def (234)

list (234)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 3: 128 calls (0.11)

[] (128)

True (128)

True (128)

True (128)

True (128)

_MessageStateHandler._is_one_message_enabled def (128)

[] (128)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 4: 108 calls (0.09)

['"""w0401 dependency\n', '"""\n', '\n', 'from __future__ import print_function\n', '\n', 'from . import func_w0401\n', '\n', 'if func_w0401:\n', ' ...

True (108)

True (108)

True (108)

True (108)

_MessageStateHandler._is_one_message_enabled def (108)

list (108)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 5: 88 calls (0.07)

['"""test code similarities\n', 'by default docstring are not considered\n', '"""\n', "__revision__ = 'id'\n", 'A = 2\n', 'B = 3\n', 'C = A + B\n', '#...

True (88)

True (88)

True (88)

True (88)

_MessageStateHandler._is_one_message_enabled def (88)

list (88)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 6: 75 calls (0.06)

['# pylint: disable=missing-module-docstring, missing-function-docstring\n', '\n', 'def test():\n', " variable = ''\n", ' variable2 = None\n', '...

True (75)

True (75)

True (75)

True (75)

_MessageStateHandler._is_one_message_enabled def (75)

list (75)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 7: 67 calls (0.06)

['# pylint: disable=invalid-name, missing-docstring\n', '# pylint: disable=unbalanced-tuple-unpacking\n', 'n = 42\n'] (3) ['try:\n', ' pass\n', 'fi...

True (67)

True (67)

True (67)

True (67)

_MessageStateHandler._is_one_message_enabled def (67)

list (67)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 8: 56 calls (0.05)

['# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html\n', '# For details: https://github.com/PyCQA/pylint/blob/main/LICEN...

True (56)

True (56)

True (56)

True (56)

_MessageStateHandler._is_one_message_enabled def (56)

[] (56)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 9: 44 calls (0.04)

['# pylint: disable=unused-argument, missing-docstring, line-too-long, too-few-public-methods\n', 'import enum\n', '\n', '\n', 'class Condiment(enum.E...

True (44)

True (44)

True (44)

True (44)

_MessageStateHandler._is_one_message_enabled def (44)

list (44)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 10: 26 calls (0.02)

['# pylint: disable=missing-docstring\n', 'from typing import List\n', '\n', 'from .b import var\n', '\n', 'LstT = List[int]\n', '\n', 'print(var)\n']...

True (26)

True (26)

True (26)

True (26)

_MessageStateHandler._is_one_message_enabled def (26)

list (26)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 11: 18 calls (0.02)

['"""Checks that disabling \'ungrouped-imports\' on an import prevents subsequent\n', 'imports from being considered ungrouped in respect to it."""\n'...

True (18)

True (18)

True (18)

True (18)

_MessageStateHandler._is_one_message_enabled def (18)

[] (18)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 12: 16 calls (0.01)

['import argparse\n', 'import math\n', 'import os\n', 'import random\n', 'import sys\n'] (3) ['import os as os\n'] (2) ['# pylint: disable=unused-impo...

True (16)

True (16)

True (16)

True (16)

_MessageStateHandler._is_one_message_enabled def (16)

[] (16)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 13: 16 calls (0.01)

['# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html\n', '# For details: https://github.com/PyCQA/pylint/blob/main/LICEN...

False (16)

False (16)

False (16)

False (16)

None (16)

list (16)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 14: 14 calls (0.01)

['r"""A raw docstring.\n', '"""\n', '\n', '\n', 'def look_busy():\n', ' xxxx = 1\n', ' yyyy = 2\n', ' zzzz = 3\n', ' wwww = 4\n', ' vvv...

True (14)

True (14)

True (14)

True (14)

_MessageStateHandler._is_one_message_enabled def (14)

list (14)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 15: 9 calls (0.01)

['"""Check for duplicate function arguments."""\n', '\n', '\n', 'def foo1(_, _): # [duplicate-argument-name]\n', ' """Function with duplicate argum...

True (9)

True (9)

True (9)

True (9)

_MessageStateHandler._is_one_message_enabled def (9)

[] (9)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 16: 8 calls (0.01)

['# https://github.com/PyCQA/pylint/issues/3525\n', '# `cyclic-import` should not be emitted if one import\n', '# is guarded by `typing.TYPE_CHECKING`...

True (8)

True (8)

True (8)

True (8)

_MessageStateHandler._is_one_message_enabled def (8)

[] (8)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 17: 5 calls (0.0)

['# pylint: disable=trailing-whitespace, missing-module-docstring, trailing-newlines, missing-final-newline\n', '\n', '# +2: [invalid-character-backsp...

True (5)

True (5)

True (5)

True (5)

_MessageStateHandler._is_one_message_enabled def (5)

list (5)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 18: 4 calls (0.0)

['# pylint: disable=duplicate-code\n', 'r"""A raw docstring.\n', '"""\n', '\n', '\n', 'def look_busy():\n', ' xxxx = 1\n', ' yyyy = 2\n', ' z...

True (4)

True (4)

True (4)

True (4)

_MessageStateHandler._is_one_message_enabled def (4)

[] (4)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 19: 4 calls (0.0)

['r"""A raw docstring.\n', '"""\n', '\n', '\n', 'def look_busy():\n', ' xxxx = 1 # pylint: disable=duplicate-code\n', ' yyyy = 2\n', ' zzzz ...

True (4)

True (4)

True (4)

True (4)

_MessageStateHandler._is_one_message_enabled def (4)

list (4)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 20: 4 calls (0.0)

['r"""A raw docstring.\n', '"""\n', '\n', '\n', 'def look_busy():\n', ' # pylint: disable=duplicate-code\n', ' xxxx = 1\n', ' yyyy = 2\n', ' ...

True (4)

True (4)

True (4)

True (4)

_MessageStateHandler._is_one_message_enabled def (4)

[] (4)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 21: 4 calls (0.0)

['@deco1(dval1)\n', '@deco2(dval2)\n', '@deco3(\n', ' dval3,\n', ' dval4\n', ')\n', 'def func1(\n', ' arg1: int = 3,\n', ' arg2: Class1 = ...

False (4)

False (4)

False (4)

True (4)

None (4)

list (4)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 22: 3 calls (0.0)

['"""test"""\n'] (3)

True (3)

True (3)

True (3)

True (3)

_MessageStateHandler._is_one_message_enabled def (3)

[] (3)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 23: 2 calls (0.0)

['"""Tests for missing-param-doc and missing-type-doc for Sphinx style docstrings\n', 'with accept-no-param-doc = no"""\n', '# pylint: disable=functio...

True (2)

True (2)

True (2)

True (2)

_MessageStateHandler._is_one_message_enabled def (2)

list (2)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 24: 2 calls (0.0)

['import one\n', 'from two import two\n', 'three\n', 'four\n', 'five\n', 'six # comments optionally ignored\n', '# even full line comment!\n', 'seven\...

True (2)

False (2)

False (2)

False (2)

None (2)

list (2)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 25: 2 calls (0.0)

['import one\n', 'from two import two\n', 'three\n', 'four\n', 'five\n', 'six # comments optionally ignored\n', '# even full line comment!\n', 'seven\...

False (2)

True (2)

False (2)

False (2)

None (2)

list (2)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 26: 2 calls (0.0)

['import one\n', 'from two import two\n', 'three\n', 'four\n', 'five\n', 'six # comments optionally ignored\n', '# even full line comment!\n', 'seven\...

False (2)

False (2)

True (2)

False (2)

None (2)

list (2)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 27: 2 calls (0.0)

['from foo import (\n', ' bar,\n', ' baz,\n', ' quux,\n', ' quuux,\n', ' quuuux,\n', ' quuuuux,\n', ')\n'] (2)

False (2)

False (2)

True (2)

False (2)

None (2)

[] (2)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 28: 2 calls (0.0)

['def func1(\n', ' arg1: int = 1,\n', ' arg2: str = "2",\n', ' arg3: int = 3,\n', ' arg4: bool = True,\n', ') -> None:\n', ' """Valid f...

False (2)

False (2)

False (2)

True (2)

None (2)

[] (2)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 29: 2 calls (0.0)

['quicksort = lambda a: qs1(a,0,len(a)-1) ; import a\n', 'qs1 = lambda a,lo,hi: qs2(a,lo,hi) if lo

False (2)

False (2)

True (2)

False (2)

None (2)

list (2)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 30: 2 calls (0.0)

['""" A file designed to have lines of similarity when compared to similar_lines_b\n', '\n', 'We use lorm-ipsum to generate \'random\' code. """\n', '...

True (2)

True (2)

False (2)

False (2)

_MessageStateHandler._is_one_message_enabled def (2)

list (2)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 31: 1 calls (0.0)

["'''''' # [empty-docstring]\n", '\n', '# pylint: disable=missing-module-docstring, missing-class-docstring, too-few-public-methods, pointless-string-...

True (1)

True (1)

True (1)

True (1)

_MessageStateHandler._is_one_message_enabled def (1)

[] (1)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines
            

Path 32: 1 calls (0.0)

['r"""Checks import position rule"""\n', '# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level\n...

True (1)

True (1)

True (1)

True (1)

_MessageStateHandler._is_one_message_enabled def (1)

[] (1)

1def stripped_lines(
2    lines: Iterable[str],
3    ignore_comments: bool,
4    ignore_docstrings: bool,
5    ignore_imports: bool,
6    ignore_signatures: bool,
7    line_enabled_callback: Callable[[str, int], bool] | None = None,
8) -> list[LineSpecifs]:
9    """Return tuples of line/line number/line type with leading/trailing white-space and
10    any ignored code features removed.
11
12    :param lines: a collection of lines
13    :param ignore_comments: if true, any comment in the lines collection is removed from the result
14    :param ignore_docstrings: if true, any line that is a docstring is removed from the result
15    :param ignore_imports: if true, any line that is an import is removed from the result
16    :param ignore_signatures: if true, any line that is part of a function signature is removed from the result
17    :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
18    :return: the collection of line/line number/line type tuples
19    """
20    if ignore_imports or ignore_signatures:
21        tree = astroid.parse("".join(lines))
22    if ignore_imports:
23        node_is_import_by_lineno = (
24            (node.lineno, isinstance(node, (nodes.Import, nodes.ImportFrom)))
25            for node in tree.body
26        )
27        line_begins_import = {
28            lineno: all(is_import for _, is_import in node_is_import_group)
29            for lineno, node_is_import_group in groupby(
30                node_is_import_by_lineno, key=lambda x: x[0]  # type: ignore[no-any-return]
31            )
32        }
33        current_line_is_import = False
34    if ignore_signatures:
35
36        def _get_functions(
37            functions: list[nodes.NodeNG], tree: nodes.NodeNG
38        ) -> list[nodes.NodeNG]:
39            """Recursively get all functions including nested in the classes from the
40            tree.
41            """
42
43            for node in tree.body:
44                if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):
45                    functions.append(node)
46
47                if isinstance(
48                    node,
49                    (nodes.ClassDef, nodes.FunctionDef, nodes.AsyncFunctionDef),
50                ):
51                    _get_functions(functions, node)
52
53            return functions
54
55        functions = _get_functions([], tree)
56        signature_lines = set(
57            chain(
58                *(
59                    range(
60                        func.lineno,
61                        func.body[0].lineno if func.body else func.tolineno + 1,
62                    )
63                    for func in functions
64                )
65            )
66        )
67
68    strippedlines = []
69    docstring = None
70    for lineno, line in enumerate(lines, start=1):
71        if line_enabled_callback is not None and not line_enabled_callback(
72            "R0801", lineno
73        ):
74            continue
75        line = line.strip()
76        if ignore_docstrings:
77            if not docstring:
78                if line.startswith('"""') or line.startswith("'''"):
79                    docstring = line[:3]
80                    line = line[3:]
81                elif line.startswith('r"""') or line.startswith("r'''"):
82                    docstring = line[1:4]
83                    line = line[4:]
84            if docstring:
85                if line.endswith(docstring):
86                    docstring = None
87                line = ""
88        if ignore_imports:
89            current_line_is_import = line_begins_import.get(
90                lineno, current_line_is_import
91            )
92            if current_line_is_import:
93                line = ""
94        if ignore_comments:
95            line = line.split("#", 1)[0].strip()
96        if ignore_signatures and lineno in signature_lines:
97            line = ""
98        if line:
99            strippedlines.append(
100                LineSpecifs(text=line, line_number=LineNumber(lineno - 1))
101            )
102    return strippedlines