Skip to content

Commit 5454250

Browse files
author
Geert Vanderkelen
committed
BUG19642249: Improve errors reporting invalid sharding keys
An extra patch in which we fix the Pylint errors for the the insort_right_rev() function.
1 parent a95e9c6 commit 5454250

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/mysql/connector/fabric/caching.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,24 @@
3636
_CACHE_TTL = 1 * 60 # 1 minute
3737

3838

39-
def insort_right_rev(a, x, lo=0, hi=None):
39+
def insort_right_rev(alist, new_element, low=0, high=None):
4040
"""Similar to bisect.insort_right but for reverse sorted lists
4141
4242
This code is similar to the Python code found in Lib/bisect.py.
4343
We simply change the comparison from 'less than' to 'greater than'.
4444
"""
4545

46-
if lo < 0:
47-
raise ValueError('lo must be non-negative')
48-
if hi is None:
49-
hi = len(a)
50-
while lo < hi:
51-
mid = (lo+hi)//2
52-
if x > a[mid]: hi = mid
53-
else: lo = mid+1
54-
a.insert(lo, x)
46+
if low < 0:
47+
raise ValueError('low must be non-negative')
48+
if high is None:
49+
high = len(alist)
50+
while low < high:
51+
middle = (low + high) // 2
52+
if new_element > alist[middle]:
53+
high = middle
54+
else:
55+
low = middle + 1
56+
alist.insert(low, new_element)
5557

5658

5759
class CacheEntry(object):

0 commit comments

Comments
 (0)