Skip to content

fix: reject non-integer bucket counts - #14991

Merged
cclauss merged 3 commits into
TheAlgorithms:masterfrom
tomatotomata:codex/bucket-sort-type-error-14970
Sep 13, 2026
Merged

fix: reject non-integer bucket counts#14991
cclauss merged 3 commits into
TheAlgorithms:masterfrom
tomatotomata:codex/bucket-sort-type-error-14970

Conversation

@tomatotomata

Copy link
Copy Markdown
Contributor

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>
@cclauss
cclauss merged commit d86f4fe into TheAlgorithms:master Sep 13, 2026
4 of 5 checks passed
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.

3 participants