Path 1: 7 calls (0.88)

Const (7)

False (6) True (1)

GeneratorExit (1)

1def is_complex_format_str(node: nodes.NodeNG) -> bool:
2    """Return whether the node represents a string with complex formatting specs."""
3    inferred = utils.safe_infer(node)
4    if inferred is None or not (
5        isinstance(inferred, nodes.Const) and isinstance(inferred.value, str)
6    ):
7        return True
8    try:
9        parsed = list(string.Formatter().parse(inferred.value))
10    except ValueError:
11        # This format string is invalid
12        return False
13    return any(format_spec for (_, _, format_spec, _) in parsed)
            

Path 2: 1 calls (0.12)

Const (1)

False (1)

ValueError (1)

1def is_complex_format_str(node: nodes.NodeNG) -> bool:
2    """Return whether the node represents a string with complex formatting specs."""
3    inferred = utils.safe_infer(node)
4    if inferred is None or not (
5        isinstance(inferred, nodes.Const) and isinstance(inferred.value, str)
6    ):
7        return True
8    try:
9        parsed = list(string.Formatter().parse(inferred.value))
10    except ValueError:
11        # This format string is invalid
12        return False
13    return any(format_spec for (_, _, format_spec, _) in parsed)