Skip to content

fix: reject non-integer bucket counts - #14991

Open
tomatotomata wants to merge 1 commit into
TheAlgorithms:masterfrom
tomatotomata:codex/bucket-sort-type-error-14970
Open

fix: reject non-integer bucket counts#14991
tomatotomata wants to merge 1 commit into
TheAlgorithms:masterfrom
tomatotomata:codex/bucket-sort-type-error-14970

Conversation

@tomatotomata

Copy link
Copy Markdown

Description

Add dedicated validation for bucket_sort's bucket_count argument. Non-integer values now raise a clear TypeError before arithmetic or bucket allocation, including on empty inputs; booleans are rejected explicitly despite inheriting from int in Python. The existing behavior for positive integer counts is unchanged.

Issue reference

Closes #14970

Validation

  • python -m doctest sorts/bucket_sort.py
  • python -m ruff check sorts/bucket_sort.py
  • git diff --check
  • Direct checks for float, bool, string, empty-input, and valid integer inputs.

I used coding assistance to prepare this focused fix and reviewed the rendered diff and test output manually. The patch is limited to sorts/bucket_sort.py.

Signed-off-by: ahmadalguydi <ahmadalgaidy@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bucket_sort has no dedicated error handling when the number of buckets in inputted as a float instead of an integer.

2 participants