devansh173 opened a new pull request, #44615:
URL: https://github.com/apache/superset/pull/44615
### SUMMARY
`cast_to_num` is documented to return `None` when a value can't be converted
to a number, but it raised `ValueError` for strings such as `"²"` or `"①"`. It
guards the `int()` call with `str.isdigit()`, which is also true for characters
that are not decimal digits, and `int()` rejects them outside of the `try`
block.
This switches the guard to `str.isdecimal()`, so those values fall through
to the existing `float()` fallback and return `None`. Regular numeric strings
(including non-ASCII decimal digits such as Arabic-Indic digits) behave as
before.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
### TESTING INSTRUCTIONS
Run the new unit test:
```
pytest tests/unit_tests/utils/test_core.py -k cast_to_num
```
Or check manually:
```python
from superset.utils.core import cast_to_num
cast_to_num("²") # before: ValueError, after: None
cast_to_num("5") # 5
```
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #44614
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]