Skip to content

Commit 492c68c

Browse files
CodeLifter-sysTheRodzz
authored andcommitted
fix(sorts): raise TypeError when bucket_count is not an integer in bucket_sort (#14970)
1 parent 3708659 commit 492c68c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

sorts/bucket_sort.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ def bucket_sort(my_list: list, bucket_count: int = 10) -> list:
7171
>>> data = [9, 2, 7, 1, 5]
7272
>>> bucket_sort(data) == sorted(data)
7373
True
74+
>>> bucket_sort([1, 2, 3], bucket_count=2.5)
75+
Traceback (most recent call last):
76+
...
77+
TypeError: bucket_count must be an integer
7478
"""
79+
if not isinstance(bucket_count, int) or isinstance(bucket_count, bool):
80+
raise TypeError("bucket_count must be an integer")
7581

7682
if len(my_list) == 0 or bucket_count <= 0:
7783
return []

0 commit comments

Comments
 (0)