Title: Validate string switch case inputs by pruthvirajgojare-source · Pull Request #99 · S-AI-Projects/TheAlgorithms-Python · GitHub
Open Graph Title: Validate string switch case inputs by pruthvirajgojare-source · Pull Request #99 · S-AI-Projects/TheAlgorithms-Python
X Title: Validate string switch case inputs by pruthvirajgojare-source · Pull Request #99 · S-AI-Projects/TheAlgorithms-Python
Description: Description Added explicit validation and edge-case handling for the string case conversion functions. Non-string input now raises a clear TypeError instead of exposing an incidental regex error; empty strings, separator-only strings, and Unicode letters now have documented, consistent behavior. Related Issue None. Fixes: Not applicable. Type of Change Bug Fix New Feature UI/UX Improvement Performance Improvement Tests Documentation Refactoring / Maintenance CI/CD Changes Made Added TypeError("input must be a string") validation in split_input; all six case converters use this validation. Preserved Unicode letters and digits while treating punctuation and underscores as separators. Made empty and separator-only values return an empty string consistently, including camel case (instead of the old "not valid string" sentinel). Added doctests covering the error path, empty input, separator-only input, and Unicode for all seven functions. Added the input probe evidence at work/R23-T046/input_probes.md. Screenshots / Recordings Not applicable; this change does not affect a UI. Testing uv run pytest strings/string_switch_case.py -v — passed; all 7 doctest suites passed. uv run python -m doctest -v strings/string_switch_case.py — passed; 40 doctest examples passed. uv run pytest strings -v — passed; 104 tests passed. uvx ruff check strings/string_switch_case.py — passed. uvx ruff format --check strings/string_switch_case.py — passed. uvx rumdl check work/R23-T046/input_probes.md — passed. Probed 10 input classes across all 7 functions, including non-strings, empty/separator-only strings, digits, Unicode, and a one-million-character string. Checklist I have tested my changes locally. I have added or updated tests, if needed. I have updated documentation, if needed. I have followed the project's coding guidelines. I have run the relevant tests and checks. I have addressed previous review feedback, if applicable (no prior feedback was present). Additional Notes The probe table below records outcomes before the change. Non-strings raised incidental TypeErrors from re.split; accented and CJK letters were silently dropped; camel case returned "not valid string" for empty input. The code change now follows the documented input contract. Input split_input to_simple_case to_complex_case to_pascal_case to_camel_case to_snake_case to_kebab_case None TypeError TypeError TypeError TypeError TypeError TypeError TypeError 123 TypeError TypeError TypeError TypeError TypeError TypeError TypeError ['a', 'b'] TypeError TypeError TypeError TypeError TypeError TypeError TypeError "" [[]] "" "" "" "not valid string" "" "" " " [[]] "" "" "" "not valid string" "" "" "---___!!!" 10 empty groups "" "" "" "not valid string" "" "" "12345" [['12345']] "12345" "12345" "12345" "12345" "12345" "12345" "café" [['caf'], []] "Caf" "caf" "Caf" "caf" "caf" "caf" "漢字" 3 empty groups "" "" "" "not valid string" "" "" 1,000,000 As 1 group len 1,000,000 len 1,000,000 len 1,000,000 len 1,000,000 len 1,000,000 len 1,000,000 The separate upstream/R23-T046 branch contains only the code change and excludes work/.
Open Graph Description: Description Added explicit validation and edge-case handling for the string case conversion functions. Non-string input now raises a clear TypeError instead of exposing an incidental regex error; e...
X Description: Description Added explicit validation and edge-case handling for the string case conversion functions. Non-string input now raises a clear TypeError instead of exposing an incidental regex error; e...
Opengraph URL: https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/99
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f5cb49a9-1c1e-3f47-a758-f3865f647afc |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9A80:102041:161100:1E47EC:6AFE05B9 |
| html-safe-nonce | c1580a299af780211754159260f24856870457db058c4398c26fee3ce2207f09 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTgwOjEwMjA0MToxNjExMDA6MUU0N0VDOjZBRkUwNUI5IiwidmlzaXRvcl9pZCI6IjIzMzI1OTQ1MTU0NTk1NzMxNzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fbc7ddc8a2c16e80090299a02aad3f8d46dbcd95700e746f6107b5aa18177cd3 |
| hovercard-subject-tag | pull_request:5371978338 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/99/files |
| twitter:image | https://avatars.githubusercontent.com/u/295325153?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/295325153?s=400&v=4 |
| og:image:alt | Description Added explicit validation and edge-case handling for the string case conversion functions. Non-string input now raises a clear TypeError instead of exposing an incidental regex error; e... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 86d46ece7c3d9b0562692f81a135cb55ad6a1c82c93ab1ac874d2f1b46b28958 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/S-AI-Projects/TheAlgorithms-Python git https://github.com/S-AI-Projects/TheAlgorithms-Python.git |
| octolytics-dimension-user_id | 351892385 |
| octolytics-dimension-user_login | S-AI-Projects |
| octolytics-dimension-repository_id | 1444141022 |
| octolytics-dimension-repository_nwo | S-AI-Projects/TheAlgorithms-Python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 63476337 |
| octolytics-dimension-repository_parent_nwo | TheAlgorithms/Python |
| octolytics-dimension-repository_network_root_id | 63476337 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/Python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5c18e6799976b7bc2f21178024289bb98edbcc85 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width