Convert the given string to exit codes. Receives digits and strings and outputs the parsed integer which represents the exit code found in exceptions.
(comma_separated_no_raise: str)
| 622 | |
| 623 | |
| 624 | def parse_no_raise(comma_separated_no_raise: str) -> list[int]: |
| 625 | """Convert the given string to exit codes. |
| 626 | |
| 627 | Receives digits and strings and outputs the parsed integer which |
| 628 | represents the exit code found in exceptions. |
| 629 | """ |
| 630 | |
| 631 | def exit_code_from_str_or_skip(s: str) -> ExitCode | None: |
| 632 | try: |
| 633 | return ExitCode.from_str(s) |
| 634 | except (KeyError, ValueError): |
| 635 | out.warn(f"WARN: no_raise value `{s}` is not a valid exit code. Skipping.") |
| 636 | return None |
| 637 | |
| 638 | return [ |
| 639 | code.value |
| 640 | for s in comma_separated_no_raise.split(",") |
| 641 | if (code := exit_code_from_str_or_skip(s)) is not None |
| 642 | ] |
| 643 | |
| 644 | |
| 645 | if TYPE_CHECKING: |
no test coverage detected
searching dependent graphs…