Repository navigation
Description
Student: Pruthviraj Gojare
Task: R23-T046 · 6 of 10
Repository: https://github.com/S-AI-Projects/TheAlgorithms-Python
Assigned working branch: student/e26b07f0834
Goal
Find inputs that crash or silently give wrong answers, and make the code raise clear exceptions as CONTRIBUTING.md requires. Probe empty strings, only separators, digits, Unicode letters and non-string input across the 7 functions.
Steps
- Try at least 8 bad inputs (wrong type, empty, negative, None, huge, unusual characters) and record what happens to each.
- Decide the correct behaviour for each (raise ValueError/TypeError with a clear message, or handle it).
- Implement it and add a doctest for every new error path.
- Document the input contract in the docstring.
- Make the code change in the repository: strings/string_switch_case.py: validation for non-string input and doctests for empty strings, separator-only and Unicode input. Re-run the automated check and the repo's own tests afterwards.
- Prepare the PR: on branch R23-T046, commit the code change plus your work/R23-T046/ evidence, put your findings in the PR description and open the PR against the org fork. For a later upstream PR, create a second branch containing only the code change (no work/ folder).
Done when
☐ PR table covers ≥8 inputs across split_input, to_simple_case, to_complex_case, to_pascal_case, to_camel_case, to_snake_case and to_kebab_case (empty, separators only, digits, Unicode, non-string).
☐ strings/string_switch_case.py raises TypeError for non-strings with doctests; empty and separator-only behaviour is documented with doctests.
☐ Existing 13 doctests pass.
Additional task guidance
Additional curated task guidance
Item:
strings/string_switch_case.py (122 lines; 13 doctests)
Task type:
Input validation
Code change (goes into the PR):
strings/string_switch_case.py: validation for non-string input and doctests for empty strings, separator-only and Unicode input.
Automated check:
uv run pytest strings/string_switch_case.py
Prerequisites:
Linux/WSL2/Codespaces with uv (https://docs.astral.sh/uv/getting-started/installation/); run uv sync --group=test once – it installs the Python version CI uses (.python-version = 3.15t) and the test dependencies, about 1–2 GB
Upstream PR rules:
Follow CONTRIBUTING.md: type hints on every parameter/return, doctests for valid and erroneous input, snake_case file names, no duplicate of an existing implementation, no hand edits to DIRECTORY.md. CI (pytest with doctests, ruff) must pass – bots close PRs without tests or type hints. Keep work/ (benchmarks, notes, property tests) out of the upstream branch; put results in the PR description.
Source (pinned):
https://github.com/TheAlgorithms/Python/blob/574d100b7181956e9c8384552fd078165e4cc326/strings/string_switch_case.py
Change:
No change recorded
PR destination:
Preserved pilot guidance
Submission checklist
- Complete this task and its checks.
- Add the required evidence and link your pull request here.
- Select this S-AI-Projects fork as the PR base repository.
- Request instructor review.
Keep this PR focused on this task. Do not submit assignment PRs to the upstream repository.
Activity