MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / parse_no_raise

Function parse_no_raise

commitizen/cli.py:628–646  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls 1

Tested by

no test coverage detected