Expected behavior
It should display the string "0" representation as defined in as_string() despite the radial graph being 0 as well
Screenshots / photos of the Turing screen
Current:
It should have been like this:
Environment:
Smart screen model: Turing 3.5”
Revision of this project: main branch
OS with version: Windows 10
Python version: Python 3.11
Hardware: AMD Ryzen 7 CPU, Nvidia GPU
Additional context
The problem lies in the Context class using truthy / falsy checks instead of checking if string or numeric value is None
# library/stats.py
class Custom:
@staticmethod
def stats():
...
- if not string_value:
+ if string_value is None:
string_value = str(numeric_value)
# Display text
theme_data = config.THEME_DATA["STATS"]["CUSTOM"][custom_stat].get(
"TEXT", None
)
- if theme_data and string_value:
+ if theme_data and string_value is not None:
display_themed_value(theme_data=theme_data, value=string_value)
# Display graph from numeric value
theme_data = config.THEME_DATA["STATS"]["CUSTOM"][custom_stat].get(
"GRAPH", None
)
- if theme_data and numeric_value:
+ if theme_data and numeric_value is not None:
display_themed_progress_bar(
theme_data=theme_data, value=numeric_value
)
# Display radial from numeric and text value
theme_data = config.THEME_DATA["STATS"]["CUSTOM"][custom_stat].get(
"RADIAL", None
)
- if theme_data and numeric_value and string_value:
+ if theme_data and numeric_value is not None and string_value is not None:
display_themed_radial_bar(
theme_data=theme_data,
value=numeric_value,
custom_text=string_value,
)
Describe the bug Custom stats do not update visuals if string or numeric value is falsy (e.g. zero or empty string) but not None
To Reproduce
theme.yaml
Expected behavior
It should display the string
"0"
representation as defined inas_string()
despite the radial graph being 0 as wellScreenshots / photos of the Turing screen![image](https://github.com/mathoudebine/turing-smart-screen-python/assets/70209942/4d2963c4-1415-476a-a408-d865bad21308)
Current:
It should have been like this:![image](https://github.com/mathoudebine/turing-smart-screen-python/assets/70209942/137f270a-a215-4222-9be5-a83c85f57bbf)
Environment:
Additional context
The problem lies in the
Context
class using truthy / falsy checks instead of checking if string or numeric value is None