Path 1: 15 calls (0.25)

Call (15)

0 (15)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 2: 13 calls (0.22)

Call (13)

0 (13)

None (13)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 3: 8 calls (0.14)

Call (8)

0 (8)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 4: 7 calls (0.12)

Call (7)

0 (6) 1 (1)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 5: 6 calls (0.1)

Call (6)

0 (6)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 6: 5 calls (0.08)

Call (5)

0 (5)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 7: 2 calls (0.03)

Call (2)

0 (2)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 8: 1 calls (0.02)

Call (1)

0 (1)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 9: 1 calls (0.02)

Call (1)

0 (1)

None (1)

IncompleteFormatString (1)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)
            

Path 10: 1 calls (0.02)

Call (1)

0 (1)

None (1)

UnsupportedFormatCharacter (1)

1def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> None:
2        """Checks that format string tokens match the supplied arguments.
3
4        Args:
5          node: AST node to be checked.
6          format_arg: Index of the format string in the node arguments.
7        """
8        num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
9        if not num_args:
10            # If no args were supplied the string is not interpolated and can contain
11            # formatting characters - it's used verbatim. Don't check any further.
12            return
13
14        format_string = node.args[format_arg].value
15        required_num_args = 0
16        if isinstance(format_string, bytes):
17            format_string = format_string.decode()
18        if isinstance(format_string, str):
19            try:
20                if self._format_style == "old":
21                    keyword_args, required_num_args, _, _ = utils.parse_format_string(
22                        format_string
23                    )
24                    if keyword_args:
25                        # Keyword checking on logging strings is complicated by
26                        # special keywords - out of scope.
27                        return
28                elif self._format_style == "new":
29                    (
30                        keyword_arguments,
31                        implicit_pos_args,
32                        explicit_pos_args,
33                    ) = utils.parse_format_method_string(format_string)
34
35                    keyword_args_cnt = len(
36                        {k for k, l in keyword_arguments if not isinstance(k, int)}
37                    )
38                    required_num_args = (
39                        keyword_args_cnt + implicit_pos_args + explicit_pos_args
40                    )
41            except utils.UnsupportedFormatCharacter as ex:
42                char = format_string[ex.index]
43                self.add_message(
44                    "logging-unsupported-format",
45                    node=node,
46                    args=(char, ord(char), ex.index),
47                )
48                return
49            except utils.IncompleteFormatString:
50                self.add_message("logging-format-truncated", node=node)
51                return
52        if num_args > required_num_args:
53            self.add_message("logging-too-many-args", node=node)
54        elif num_args < required_num_args:
55            self.add_message("logging-too-few-args", node=node)