fix(application): preserve non-success dispatcher return codes - #1068
Conversation
|
Hi! Just gently checking whether there’s anything I should adjust here. This PR is intended to preserve non-success dispatcher return codes while keeping the existing success-path behaviour unchanged. Happy to rework it if there’s a preferred direction, or to close it if this should not move forward. |
mr-cal
left a comment
There was a problem hiding this comment.
LGTM, thanks! Can you resolve the conflicts so we can land this?
This class got simplified, so your changes should be even simpler (one instance of this logic instead of two).
…119-exit-code # Conflicts: # craft_application/application.py
|
FYI to anyone who looks at this PR in the future - this PR makes a semantic correction of doing an explicit comparison against None, rather than relying on falsiness. But since the only falsy exit code is 0 ( |
Summary
Preserve explicit return codes from
dispatcher.run()inApplication._run_inner()while keeping the existing success fallback for commands that do not return a value.Previously,
_run_inner()used:dispatcher.run() or os.EX_OKdispatcher.run() or 0This meant falsy explicit return codes could be normalized incorrectly. In particular, this change avoids relying on truthiness and only falls back when
dispatcher.run()returnsNone.With this change:
Nonefalls back toos.EX_OK0is preserved as0Testing