Repository navigation
fix(api): decide module conditions by result truthiness, not exception-presence - #398
chinmayajha wants to merge 1 commit into
Conversation
|
This is quite a breaking change |
5e347c7 to
5fb7317
Compare
|
|
before moving forward with this, |
…sence Closes mozarkai#385. FlowControl._handle_module_condition decided whether a module-name condition was true by whether execute_module() *raised*, not by the truthiness of its result. A module that ran successfully but returned an empty/falsy result (e.g. []) was treated as true and its target executed anyway — contradicting both the _evaluate_conditions docstring ("returns the result of executing the module if non-empty") and the sibling expression path _is_condition_true, which already uses bool(result). Compute the condition as `bool(result)` (a raising module is false, as in _is_condition_true), apply the optional `!` inversion, and only run the target when the condition is true — otherwise return None so the caller falls through to the else branch. This also collapses the duplicated target-execution/E0401 wrapping into a single path. The two tests that pinned the intended behaviour as xfail(strict) in test_flow_control_all.py (test_falsy_module_skips_target_runs_else, test_falsy_module_no_else_returns_none) now pass; their markers are removed. Behaviour change: a suite that relied on "an empty-result module condition still runs its target" will now take the else branch instead.
5fb7317 to
e0cc009
Compare
|
thakur-patel
left a comment
There was a problem hiding this comment.
Product review: approved. I've reviewed the intent and use case of this change, and it makes sense from a user and product point of view. This covers product intent and use case only. I haven't reviewed the implementation, so please rely on the code reviewers for that.
Approval withdrawn: posted by mistake. This PR is outside the product review scope.



Fixes #385.
FlowControl._handle_module_conditiontreated a module-name condition as true whenever the module ran without raising — ignoringbool(result). A module returning an empty/falsy result therefore wrongly ran its target (and skippedelse), contradicting the docstring and the sibling expression path_is_condition_true.This decides truth by
bool(result)for both the plain and inverted (!) forms, and flips the twoxfail(strict)tests added in the test overhaul to passing (test_falsy_module_skips_target_runs_else,test_falsy_module_no_else_returns_none).