Skip to content

--no-raise is not possible with --debug #1294

Closed

Description

@diefans

Description

The actual code is clearly excluding --no-raise if --debug is set (https://github.com/commitizen-tools/commitizen/blob/master/commitizen/cli.py#L640-L648)

    if args.debug:
        logging.getLogger("commitizen").setLevel(logging.DEBUG)
        sys.excepthook = commitizen_debug_excepthook
    elif args.no_raise:
        no_raise_exit_codes = parse_no_raise(args.no_raise)
        no_raise_debug_excepthook = partial(
            commitizen_excepthook, no_raise=no_raise_exit_codes
        )
        sys.excepthook = no_raise_debug_excepthook

Since sys.excepthook is defined here https://github.com/commitizen-tools/commitizen/blob/master/commitizen/cli.py#L564
we can have possible working solution by iteratively precising the partial e.g.:

    if args.debug:
        logging.getLogger("commitizen").setLevel(logging.DEBUG)
        sys.excepthook = commitizen_debug_excepthook
    if args.no_raise:
        no_raise_exit_codes = parse_no_raise(args.no_raise)
        no_raise_debug_excepthook = partial(
            sys.excepthook, no_raise=no_raise_exit_codes
        )
        sys.excepthook = no_raise_debug_excepthook

Steps to reproduce

cz --debug --no-raise 21 bump --yes --changelog --dry-run

Current behavior

The usage of --debug prevents the usage of --no-raise

Desired behavior

I want to use --debug and --no-raise together.

Screenshots

No response

Environment

cz version
3.31.0

Activity

  1. bearomorphism commented on Dec 3, 2025

    @bearomorphism
    Collaborator

    @Lee-W @woile is there any reason why elif is used here?

    The change is introduced in #489

  2. woile commented on Dec 3, 2025

    @woile
    Member

    At the time, I think because it's loading a new hook, it was an elif. But if they could somehow be combined, they it would be ok

  3. added 7 commits that reference this issue on Dec 3, 2025
    91a40dd
    02c929f
    a08b162
    0768958
    9f9fc0f
    ebc0709
    6531d11
  4. added a commit that references this issue on Dec 11, 2025
    51e0ac5
  5. added a commit that references this issue on Dec 11, 2025
    bc2ba39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions