pallets / jinja

A very fast and expressive template engine.
https://jinja.palletsprojects.com
BSD 3-Clause "New" or "Revised" License
10.23k stars 1.6k forks source link

Slightly improve clarity of logical bool ops #1938

Open sirosen opened 6 months ago

sirosen commented 6 months ago

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