Path 1: 1535 calls (0.48)

Expr (1535)

None (1535)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 2: 809 calls (0.25)

Expr (809)

None (809)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 3: 309 calls (0.1)

Expr (309)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 4: 169 calls (0.05)

Expr (169)

None (169)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 5: 158 calls (0.05)

Expr (158)

None (158)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 6: 123 calls (0.04)

Expr (123)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 7: 54 calls (0.02)

Expr (54)

None (54)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 8: 35 calls (0.01)

Expr (35)

None (35)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 9: 10 calls (0.0)

Expr (10)

None (10)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 10: 5 calls (0.0)

Expr (5)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 11: 4 calls (0.0)

Expr (4)

None (4)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 12: 4 calls (0.0)

Expr (4)

None (4)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 13: 3 calls (0.0)

Expr (3)

None (3)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 14: 2 calls (0.0)

Expr (2)

None (2)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 15: 1 calls (0.0)

Expr (1)

None (1)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)
            

Path 16: 1 calls (0.0)

Expr (1)

None (1)

1@utils.only_required_for_messages(
2        "pointless-statement",
3        "pointless-exception-statement",
4        "pointless-string-statement",
5        "expression-not-assigned",
6        "named-expr-without-context",
7    )
8    def visit_expr(self, node: nodes.Expr) -> None:
9        """Check for various kind of statements without effect."""
10        expr = node.value
11        if isinstance(expr, nodes.Const) and isinstance(expr.value, str):
12            # treat string statement in a separated message
13            # Handle PEP-257 attribute docstrings.
14            # An attribute docstring is defined as being a string right after
15            # an assignment at the module level, class level or __init__ level.
16            scope = expr.scope()
17            if isinstance(scope, (nodes.ClassDef, nodes.Module, nodes.FunctionDef)):
18                if isinstance(scope, nodes.FunctionDef) and scope.name != "__init__":
19                    pass
20                else:
21                    sibling = expr.previous_sibling()
22                    if (
23                        sibling is not None
24                        and sibling.scope() is scope
25                        and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
26                    ):
27                        return
28            self.add_message("pointless-string-statement", node=node)
29            return
30
31        # Warn W0133 for exceptions that are used as statements
32        if isinstance(expr, nodes.Call):
33            name = ""
34            if isinstance(expr.func, nodes.Name):
35                name = expr.func.name
36            elif isinstance(expr.func, nodes.Attribute):
37                name = expr.func.attrname
38
39            # Heuristic: only run inference for names that begin with an uppercase char
40            # This reduces W0133's coverage, but retains acceptable runtime performance
41            # For more details, see: https://github.com/PyCQA/pylint/issues/8073
42            inferred = utils.safe_infer(expr) if name[:1].isupper() else None
43            if isinstance(inferred, objects.ExceptionInstance):
44                self.add_message(
45                    "pointless-exception-statement", node=node, confidence=INFERENCE
46                )
47            return
48
49        # Ignore if this is :
50        # * the unique child of a try/except body
51        # * a yield statement
52        # * an ellipsis (which can be used on Python 3 instead of pass)
53        # warn W0106 if we have any underlying function call (we can't predict
54        # side effects), else pointless-statement
55        if (
56            isinstance(expr, (nodes.Yield, nodes.Await))
57            or (isinstance(node.parent, nodes.TryExcept) and node.parent.body == [node])
58            or (isinstance(expr, nodes.Const) and expr.value is Ellipsis)
59        ):
60            return
61        if isinstance(expr, nodes.NamedExpr):
62            self.add_message("named-expr-without-context", node=node, confidence=HIGH)
63        elif any(expr.nodes_of_class(nodes.Call)):
64            self.add_message(
65                "expression-not-assigned", node=node, args=expr.as_string()
66            )
67        else:
68            self.add_message("pointless-statement", node=node)