Path 1: 58 calls (0.59)

Call (58)

'error' (39) 'info' (14) 'debug' (4) 'warn' (1)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 2: 9 calls (0.09)

Call (9)

'debug' (4) 'info' (4) 'error' (1)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 3: 9 calls (0.09)

Call (9)

'debug' (3) 'warn' (2) 'warning' (2) 'info' (1) 'exception' (1)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 4: 6 calls (0.06)

Call (6)

'info' (3) 'error' (2) 'debug' (1)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 5: 4 calls (0.04)

Call (4)

'getLogger' (4)

None (4)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 6: 3 calls (0.03)

Call (3)

'log' (3)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 7: 2 calls (0.02)

Call (2)

'log' (2)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 8: 2 calls (0.02)

Call (2)

'error' (2)

None (2)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 9: 2 calls (0.02)

Call (2)

'log' (2)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 10: 2 calls (0.02)

Call (2)

'log' (2)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 11: 1 calls (0.01)

Call (1)

'warn' (1)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )
            

Path 12: 1 calls (0.01)

Call (1)

'log' (1)

1def _check_log_method(self, node: nodes.Call, name: str) -> None:
2        """Checks calls to logging.log(level, format, *format_args)."""
3        if name == "log":
4            if node.starargs or node.kwargs or len(node.args) < 2:
5                # Either a malformed call, star args, or double-star args. Beyond
6                # the scope of this checker.
7                return
8            format_pos: Literal[0, 1] = 1
9        elif name in CHECKED_CONVENIENCE_FUNCTIONS:
10            if node.starargs or node.kwargs or not node.args:
11                # Either no args, star args, or double-star args. Beyond the
12                # scope of this checker.
13                return
14            format_pos = 0
15        else:
16            return
17
18        format_arg = node.args[format_pos]
19        if isinstance(format_arg, nodes.BinOp):
20            binop = format_arg
21            emit = binop.op == "%"
22            if binop.op == "+":
23                total_number_of_strings = sum(
24                    1
25                    for operand in (binop.left, binop.right)
26                    if self._is_operand_literal_str(utils.safe_infer(operand))
27                )
28                emit = total_number_of_strings > 0
29            if emit:
30                self.add_message(
31                    "logging-not-lazy",
32                    node=node,
33                    args=(self._helper_string(node),),
34                )
35        elif isinstance(format_arg, nodes.Call):
36            self._check_call_func(format_arg)
37        elif isinstance(format_arg, nodes.Const):
38            self._check_format_string(node, format_pos)
39        elif isinstance(format_arg, nodes.JoinedStr):
40            if str_formatting_in_f_string(format_arg):
41                return
42            self.add_message(
43                "logging-fstring-interpolation",
44                node=node,
45                args=(self._helper_string(node),),
46            )