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

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

sirosen
Copy link
Contributor

@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

@sirosen sirosen force-pushed the minor-doc-clarification branch from 5631a2d to 5eabb03 Compare February 16, 2024 07:47
@sirosen sirosen force-pushed the minor-doc-clarification branch from 5eabb03 to f92a2c1 Compare December 16, 2024 19:29
@davidism davidism added the docs label Dec 18, 2024
@davidism davidism changed the base branch from main to stable December 18, 2024 16:55
@davidism davidism force-pushed the minor-doc-clarification branch from f92a2c1 to 60a0354 Compare December 18, 2024 16:56
@davidism davidism added this to the 3.1.5 milestone Dec 18, 2024
@davidism davidism force-pushed the minor-doc-clarification branch from 60a0354 to 64a6bd1 Compare December 18, 2024 17:12
@davidism
Copy link
Member

I added further clarification.

@davidism davidism merged commit 13c42b3 into pallets:stable Dec 18, 2024
1 check passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants