docs/guides/lint_rules/rules/branch_expression.md
⚠️ Runtime ❌ Not Fixable
MR002: Branch statements with output expressions that won't be displayed.
When output expressions are nested inside branches at the end of a cell:
This is a runtime issue because it causes unexpected behavior where the user's intended output is silently ignored.
Problematic:
if condition:
mo.md("Result A") # Won't be displayed
else:
mo.md("Result B") # Won't be displayed
Problematic:
match value:
case 1:
"Too short" # Won't be displayed
case _:
value # Won't be displayed
Not flagged:
if condition:
print("Debug message") # Function calls
Solution:
# Assign to a variable that marimo will display
result = mo.md("Result A") if condition else mo.md("Result B")
result
Solution:
# Create a default variable for response.
result = None
if condition:
result = expr
else:
result = other
result
Alternative Solution (if no output intended):
# Use a dummy variable to indicate intentional suppression
if condition:
_ = expr
else:
_ = other