Path 1: 182 calls (0.78)

'{}' (11) '{Param_1} {Param_2}' (9) '{} {}' (7) 'String {Param} {Param}' (6) '{Param_1} {Param_2} {Param_3}' (6) '{a[Param_1]}{a[Param_2]}' (6) 'Strin...

'' (61) '0' (33) 'Param_1' (24) 'Param_2' (15) '1' (14) 'named' (14) 'Param' (12) 'a' (11) 'Param_3' (6) 'a[Param_1]' (6)

GeneratorExit (182)

1def collect_string_fields(format_string: str) -> Iterable[str | None]:
2    """Given a format string, return an iterator
3    of all the valid format fields.
4
5    It handles nested fields as well.
6    """
7    formatter = string.Formatter()
8    # pylint: disable = too-many-try-statements
9    try:
10        parseiterator = formatter.parse(format_string)
11        for result in parseiterator:
12            if all(item is None for item in result[1:]):
13                # not a replacement format
14                continue
15            name = result[1]
16            nested = result[2]
17            yield name
18            if nested:
19                yield from collect_string_fields(nested)
20    except ValueError as exc:
21        # Probably the format string is invalid.
22        if exc.args[0].startswith("cannot switch from manual"):
23            # On Jython, parsing a string with both manual
24            # and automatic positions will fail with a ValueError,
25            # while on CPython it will simply return the fields,
26            # the validation being done in the interpreter (?).
27            # We're just returning two mixed fields in order
28            # to trigger the format-combined-specification check.
29            yield ""
30            yield "1"
31            return
32        raise IncompleteFormatString(format_string) from exc
            

Path 2: 21 calls (0.09)

'20' (4) 'String' (4) '10' (4) '5' (3) ',d' (2) 'constant string' (1) 'r' (1) '{{}}' (1) '*^30' (1)

1def collect_string_fields(format_string: str) -> Iterable[str | None]:
2    """Given a format string, return an iterator
3    of all the valid format fields.
4
5    It handles nested fields as well.
6    """
7    formatter = string.Formatter()
8    # pylint: disable = too-many-try-statements
9    try:
10        parseiterator = formatter.parse(format_string)
11        for result in parseiterator:
12            if all(item is None for item in result[1:]):
13                # not a replacement format
14                continue
15            name = result[1]
16            nested = result[2]
17            yield name
18            if nested:
19                yield from collect_string_fields(nested)
20    except ValueError as exc:
21        # Probably the format string is invalid.
22        if exc.args[0].startswith("cannot switch from manual"):
23            # On Jython, parsing a string with both manual
24            # and automatic positions will fail with a ValueError,
25            # while on CPython it will simply return the fields,
26            # the validation being done in the interpreter (?).
27            # We're just returning two mixed fields in order
28            # to trigger the format-combined-specification check.
29            yield ""
30            yield "1"
31            return
32        raise IncompleteFormatString(format_string) from exc
            

Path 3: 17 calls (0.07)

'{0:>{1}}' (3) '{a!r:20}' (2) 'Bad key: {:r}' (1) '{0!r:20}' (1) '{!r:20}' (1) '{0:{a[1]}} {a}' (1) '{:>{}}' (1) '{0:{a[1]}}' (1) '{0:{a.x}}' (1) '{:5...

'' (9) '0' (7) 'a' (3) '1' (3) 'a[1]' (2) 'a.x' (1) 'field' (1)

GeneratorExit (17)

1def collect_string_fields(format_string: str) -> Iterable[str | None]:
2    """Given a format string, return an iterator
3    of all the valid format fields.
4
5    It handles nested fields as well.
6    """
7    formatter = string.Formatter()
8    # pylint: disable = too-many-try-statements
9    try:
10        parseiterator = formatter.parse(format_string)
11        for result in parseiterator:
12            if all(item is None for item in result[1:]):
13                # not a replacement format
14                continue
15            name = result[1]
16            nested = result[2]
17            yield name
18            if nested:
19                yield from collect_string_fields(nested)
20    except ValueError as exc:
21        # Probably the format string is invalid.
22        if exc.args[0].startswith("cannot switch from manual"):
23            # On Jython, parsing a string with both manual
24            # and automatic positions will fail with a ValueError,
25            # while on CPython it will simply return the fields,
26            # the validation being done in the interpreter (?).
27            # We're just returning two mixed fields in order
28            # to trigger the format-combined-specification check.
29            yield ""
30            yield "1"
31            return
32        raise IncompleteFormatString(format_string) from exc
            

Path 4: 4 calls (0.02)

'Read {l} rows' (2) ' I am a {} docstring.' (1) '{} Come Forth!' (1)

'' (2) 'l' (2)

GeneratorExit (4)

1def collect_string_fields(format_string: str) -> Iterable[str | None]:
2    """Given a format string, return an iterator
3    of all the valid format fields.
4
5    It handles nested fields as well.
6    """
7    formatter = string.Formatter()
8    # pylint: disable = too-many-try-statements
9    try:
10        parseiterator = formatter.parse(format_string)
11        for result in parseiterator:
12            if all(item is None for item in result[1:]):
13                # not a replacement format
14                continue
15            name = result[1]
16            nested = result[2]
17            yield name
18            if nested:
19                yield from collect_string_fields(nested)
20    except ValueError as exc:
21        # Probably the format string is invalid.
22        if exc.args[0].startswith("cannot switch from manual"):
23            # On Jython, parsing a string with both manual
24            # and automatic positions will fail with a ValueError,
25            # while on CPython it will simply return the fields,
26            # the validation being done in the interpreter (?).
27            # We're just returning two mixed fields in order
28            # to trigger the format-combined-specification check.
29            yield ""
30            yield "1"
31            return
32        raise IncompleteFormatString(format_string) from exc
            

Path 5: 4 calls (0.02)

'Read {l:,d} rows' (2) '{field:10}{{}}' (1) '{:5}{}{{}}{}' (1)

'' (3) 'l' (2) 'field' (1)

GeneratorExit (4)

1def collect_string_fields(format_string: str) -> Iterable[str | None]:
2    """Given a format string, return an iterator
3    of all the valid format fields.
4
5    It handles nested fields as well.
6    """
7    formatter = string.Formatter()
8    # pylint: disable = too-many-try-statements
9    try:
10        parseiterator = formatter.parse(format_string)
11        for result in parseiterator:
12            if all(item is None for item in result[1:]):
13                # not a replacement format
14                continue
15            name = result[1]
16            nested = result[2]
17            yield name
18            if nested:
19                yield from collect_string_fields(nested)
20    except ValueError as exc:
21        # Probably the format string is invalid.
22        if exc.args[0].startswith("cannot switch from manual"):
23            # On Jython, parsing a string with both manual
24            # and automatic positions will fail with a ValueError,
25            # while on CPython it will simply return the fields,
26            # the validation being done in the interpreter (?).
27            # We're just returning two mixed fields in order
28            # to trigger the format-combined-specification check.
29            yield ""
30            yield "1"
31            return
32        raise IncompleteFormatString(format_string) from exc
            

Path 6: 3 calls (0.01)

'{} {' (1) '{} }' (1) 'a {} {' (1)

'' (3)

IncompleteFormatString (3)

1def collect_string_fields(format_string: str) -> Iterable[str | None]:
2    """Given a format string, return an iterator
3    of all the valid format fields.
4
5    It handles nested fields as well.
6    """
7    formatter = string.Formatter()
8    # pylint: disable = too-many-try-statements
9    try:
10        parseiterator = formatter.parse(format_string)
11        for result in parseiterator:
12            if all(item is None for item in result[1:]):
13                # not a replacement format
14                continue
15            name = result[1]
16            nested = result[2]
17            yield name
18            if nested:
19                yield from collect_string_fields(nested)
20    except ValueError as exc:
21        # Probably the format string is invalid.
22        if exc.args[0].startswith("cannot switch from manual"):
23            # On Jython, parsing a string with both manual
24            # and automatic positions will fail with a ValueError,
25            # while on CPython it will simply return the fields,
26            # the validation being done in the interpreter (?).
27            # We're just returning two mixed fields in order
28            # to trigger the format-combined-specification check.
29            yield ""
30            yield "1"
31            return
32        raise IncompleteFormatString(format_string) from exc
            

Path 7: 1 calls (0.0)

'0} - {1}' (1)

IncompleteFormatString (1)

1def collect_string_fields(format_string: str) -> Iterable[str | None]:
2    """Given a format string, return an iterator
3    of all the valid format fields.
4
5    It handles nested fields as well.
6    """
7    formatter = string.Formatter()
8    # pylint: disable = too-many-try-statements
9    try:
10        parseiterator = formatter.parse(format_string)
11        for result in parseiterator:
12            if all(item is None for item in result[1:]):
13                # not a replacement format
14                continue
15            name = result[1]
16            nested = result[2]
17            yield name
18            if nested:
19                yield from collect_string_fields(nested)
20    except ValueError as exc:
21        # Probably the format string is invalid.
22        if exc.args[0].startswith("cannot switch from manual"):
23            # On Jython, parsing a string with both manual
24            # and automatic positions will fail with a ValueError,
25            # while on CPython it will simply return the fields,
26            # the validation being done in the interpreter (?).
27            # We're just returning two mixed fields in order
28            # to trigger the format-combined-specification check.
29            yield ""
30            yield "1"
31            return
32        raise IncompleteFormatString(format_string) from exc
            

Path 8: 1 calls (0.0)

'There are {.:2f} undiscovered errors.' (1)

'.' (1)

GeneratorExit (1)

1def collect_string_fields(format_string: str) -> Iterable[str | None]:
2    """Given a format string, return an iterator
3    of all the valid format fields.
4
5    It handles nested fields as well.
6    """
7    formatter = string.Formatter()
8    # pylint: disable = too-many-try-statements
9    try:
10        parseiterator = formatter.parse(format_string)
11        for result in parseiterator:
12            if all(item is None for item in result[1:]):
13                # not a replacement format
14                continue
15            name = result[1]
16            nested = result[2]
17            yield name
18            if nested:
19                yield from collect_string_fields(nested)
20    except ValueError as exc:
21        # Probably the format string is invalid.
22        if exc.args[0].startswith("cannot switch from manual"):
23            # On Jython, parsing a string with both manual
24            # and automatic positions will fail with a ValueError,
25            # while on CPython it will simply return the fields,
26            # the validation being done in the interpreter (?).
27            # We're just returning two mixed fields in order
28            # to trigger the format-combined-specification check.
29            yield ""
30            yield "1"
31            return
32        raise IncompleteFormatString(format_string) from exc