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

Fix boolean correctness for floats #281

Merged
merged 2 commits into from
Apr 15, 2022
Merged

Fix boolean correctness for floats #281

merged 2 commits into from
Apr 15, 2022

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Mar 25, 2022

From pr 278, floats did not properly adhere to the boolean behavior specified in the jmespath spec:

A false value corresponds to any of the following conditions:

Empty list: []
Empty object: {}
Empty string: ""
False boolean: false
Null value: null

A true value corresponds to any value that is not false.

So specifically, a value of 0.0 should NOT evaluate to a false value. However, in python, this is the case:

>>> "true value" if 0.0 else "false value"
'false value'

So we need to explicitly override python's behavior here.

@jamesls jamesls merged commit 9eb120d into develop Apr 15, 2022
bors bot added a commit to meilisearch/meilisearch-aws that referenced this pull request Jun 20, 2022
97: Bump jmespath from 1.0.0 to 1.0.1 r=alallema a=dependabot[bot]

Bumps [jmespath](https://github.com/jmespath/jmespath.py) from 1.0.0 to 1.0.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/jmespath/jmespath.py/blob/develop/CHANGELOG.rst">jmespath's changelog</a>.</em></p>
<blockquote>
<h1>1.0.1</h1>
<ul>
<li>Add support for Python 3.11
(<code>issue [#285](jmespath/jmespath.py#285) &lt;https://github.com/jmespath/jmespath.py/issues/285&gt;</code>__)</li>
<li>Fix boolean correctness for floats
(<code>issue [#281](jmespath/jmespath.py#281) &lt;https://github.com/jmespath/jmespath.py/issues/281&gt;</code>__)</li>
<li>Fix Python 3.9 warning about random sampling used in parser cache.
(<code>issue [#216](jmespath/jmespath.py#216) &lt;https://github.com/jmespath/jmespath.py/issues/216&gt;</code>__)</li>
<li>Fix Python 3.8 warning for type comparisons
(<code>issue [#210](jmespath/jmespath.py#210) &lt;https://github.com/jmespath/jmespath.py/issues/268&gt;</code>__)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/jmespath/jmespath.py/commit/e600d11e5d4e90b0d7f67882756fffc90a52eb36"><code>e600d11</code></a> Merge branch 'release-1.0.1' into master</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/42b28dadc328606c4482745f07df29100d5f13c2"><code>42b28da</code></a> Bump version to 1.0.1</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/70cf143bb89eb32770d114b0ab84705970f1f8e6"><code>70cf143</code></a> Merge branch '3.11' into develop</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/5a9eb364e89f98c2f3367bd04a9b3580ecd47b19"><code>5a9eb36</code></a> Add testing for Python 3.11</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/da70f4ea94609f87d1ccd3b50809ea8b09cfa47f"><code>da70f4e</code></a> Merge branch 'sync-tests' into develop</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/ebad3021e3ae2a67ad68dd60aa1ef111f4ace3a5"><code>ebad302</code></a> Sync upstream test from jmespath.test</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/9eb120d75cab800117c2e6649f27e3a37a9b7748"><code>9eb120d</code></a> Merge branch 'float_fix' into develop</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/0cb65901fa987684764190d7146a398a7d5c584c"><code>0cb6590</code></a> Merge branch 'changelog10' into develop</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/48a029549ea8c74561fe10c9f4062c1a10cc4da0"><code>48a0295</code></a> Add additional compliance tests for verifying float/boolean correctness</li>
<li><a href="https://github.com/jmespath/jmespath.py/commit/bd6cdba2e184af7a2d2799f03a17eacc27ebd9d1"><code>bd6cdba</code></a> Merge branch 'py38_warning' into develop</li>
<li>Additional commits viewable in <a href="https://github.com/jmespath/jmespath.py/compare/1.0.0...1.0.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=jmespath&package-manager=pip&previous-version=1.0.0&new-version=1.0.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

You can trigger a rebase of this PR by commenting ``@dependabot` rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- ``@dependabot` rebase` will rebase this PR
- ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it
- ``@dependabot` merge` will merge this PR after your CI passes on it
- ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it
- ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging
- ``@dependabot` reopen` will reopen this PR if it is closed
- ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

2 participants