Skip to content

Commit

Permalink
Add a warning when capitalized booleans (improper JSON) appear in que…
Browse files Browse the repository at this point in the history
…ry (#213)

* Add a warning when capitalized booleans appear in query

The warning from signac.filterparse._cast is burried in the shell and
automatically searching for capitalized boolean string is likely not
the expected result.

* Update changelog

* Update warnings per code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Silence pre commit

* Update signac_dashboard/dashboard.py

Co-authored-by: Joshua A. Anderson <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Joshua A. Anderson <[email protected]>
  • Loading branch information
3 people authored Mar 15, 2024
1 parent ac970e0 commit 21f2cca
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ Changes

The **signac-dashboard** package follows `semantic versioning <https://semver.org/>`_.

Version 0.7
===========

[0.7.0] -- 2024-xx-xx
---------------------

Updated
+++++

- Feedback when querying for Python booleans instead of JSON booleans (#213).

Version 0.6
===========

Expand Down
16 changes: 16 additions & 0 deletions signac_dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,22 @@ def _job_search(self, query):
try:
f = json.loads(query)
except json.JSONDecodeError:
if "True" in query and "False" in query:
flash(
'Interpreting "True" and "False" as strings. For'
'boolean values use "true" and "false".',
"warning",
)
elif "True" in query:
flash(
'Interpreting "True" as a string. For a boolean value use "true".',
"warning",
)
elif "False" in query:
flash(
'Interpreting "False" as a string. For a boolean value use "false".',
"warning",
)
query = shlex.split(query)
f = signac.filterparse.parse_filter_arg(query)
flash(f"Search string interpreted as '{json.dumps(f)}'.")
Expand Down

0 comments on commit 21f2cca

Please sign in to comment.