Commit eea1bac
fix: raise ValueError in encode() for non-lowercase input (#14936)
* fix: raise ValueError in encode() for non-lowercase input
encode() previously accepted uppercase letters, digits, and other
non-lowercase characters silently, producing incorrect/out-of-range
values (e.g. negative numbers for uppercase letters) instead of
failing. Add input validation using str.islower() and str.isalpha()
to raise a ValueError when the input isn't purely lowercase a-z.
Added a doctest covering the new error case.
* resolved doctest
* Fix Ruff 0.16 lint failures
* Enhance encode function error handling examples
Update error handling in encode function to include examples for mixed case and invalid characters.
* Fix indentation in test_cancer_data function
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 758d487 commit eea1bac
2 files changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
16 | 28 | | |
| 29 | + | |
| 30 | + | |
17 | 31 | | |
18 | 32 | | |
19 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| |||
0 commit comments