Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slightly improve clarity of logical bool ops #1938

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sirosen
Copy link

@sirosen sirosen commented Feb 16, 2024

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

Footnotes

  1. https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant