jinja icon indicating copy to clipboard operation
jinja copied to clipboard

Slightly improve clarity of logical bool ops

Open sirosen opened this issue 4 months ago • 0 comments

The doc states that these "return true" but more precisely they're the "typical" short-circuiting boolean operations with Python-like semantics. and and or may not return booleans at all depending on their inputs.


I had a coworker express the expectation that x or y in a Jinja template would return a bool, in a context in which x and y are both str | None, based on this section of the docs. I don't read the doc in this way, but strictly speaking that's what it says (these don't say that they're Python-like boolean operations -- they say they "return true").

I think the clarification is possibly helpful and at worst harmless. It was written based off of the Python documentation for the boolean operators.^1

sirosen avatar Feb 16 '24 07:02 sirosen