Skip to content

Commit 17180fe

Browse files
committed
ruff format acts differently under tox ... not sure why
1 parent 3a536a0 commit 17180fe

8 files changed

+40
-39
lines changed

Diff for: src/sortedcontainers/sortedlist.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1450,10 +1450,10 @@ def __imul__(self, num):
14501450
return self
14511451

14521452
def __make_cmp(seq_op, symbol, doc):
1453-
'Make comparator method.'
1453+
"Make comparator method."
14541454

14551455
def comparer(self, other):
1456-
'Compare method for sorted list and sequence.'
1456+
"Compare method for sorted list and sequence."
14571457
if not isinstance(other, Sequence):
14581458
return NotImplemented
14591459

@@ -1587,7 +1587,7 @@ def _check(self):
15871587

15881588

15891589
def identity(value):
1590-
'Identity function.'
1590+
"Identity function."
15911591
return value
15921592

15931593

@@ -1658,7 +1658,7 @@ def __new__(cls, iterable=None, key=identity):
16581658

16591659
@property
16601660
def key(self):
1661-
'Function used to extract comparison key from values.'
1661+
"Function used to extract comparison key from values."
16621662
return self._key
16631663

16641664
def clear(self):

Diff for: src/sortedcontainers/sortedset.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ def __delitem__(self, index):
250250
del _list[index]
251251

252252
def __make_cmp(set_op, symbol, doc):
253-
'Make comparator method.'
253+
"Make comparator method."
254254

255255
def comparer(self, other):
256-
'Compare method for sorted set and set.'
256+
"Compare method for sorted set and set."
257257
if isinstance(other, SortedSet):
258258
return set_op(self._set, other._set)
259259
elif isinstance(other, Set):

Diff for: tests/benchmark_scale.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777

7878
def iter_with_description(iterable, description=''):
79-
'Placeholder iterator function with ignored description parameter.'
79+
"Placeholder iterator function with ignored description parameter."
8080
return iter(iterable)
8181

8282

@@ -119,7 +119,7 @@ def init_sorted_list(sl, size, moment=5, fraction=0.1):
119119
total = 0
120120

121121
class WhileIterator:
122-
'Convert for-loop to while-loop with length estimate.'
122+
"Convert for-loop to while-loop with length estimate."
123123

124124
def __iter__(self):
125125
while total < size:
@@ -171,11 +171,11 @@ def __len__(self):
171171

172172

173173
def timeit(func):
174-
'Decorator to time function calls.'
174+
"Decorator to time function calls."
175175

176176
@ft.wraps(func)
177177
def wrapper(*args, **kwargs):
178-
'Return timed duration of function call. Ignores function result.'
178+
"Return timed duration of function call. Ignores function result."
179179
start = time.perf_counter()
180180
result = func(*args, **kwargs)
181181
end = time.perf_counter()
@@ -186,26 +186,26 @@ def wrapper(*args, **kwargs):
186186

187187
@timeit
188188
def add(obj, numbers):
189-
'Repeatedly add number from numbers to sorted list.'
189+
"Repeatedly add number from numbers to sorted list."
190190
for number in PROGRESS(numbers, 'add'):
191191
obj.add(number)
192192

193193

194194
@timeit
195195
def delitem(obj, indices):
196-
'Repeatedly delete values from sorted list by index in indices.'
196+
"Repeatedly delete values from sorted list by index in indices."
197197
for index in PROGRESS(indices, 'del'):
198198
del obj[index]
199199

200200

201201
def randvalues(limit, fraction=0.001):
202-
'Return fraction of limit random values between 0 and limit.'
202+
"Return fraction of limit random values between 0 and limit."
203203
iterable = PROGRESS(xrange(int(limit * fraction)), 'randvalues')
204204
return [random.randrange(limit) for each in iterable]
205205

206206

207207
def randindices(limit, fraction=0.002):
208-
'Return fraction of limit random indices counting down from limit.'
208+
"Return fraction of limit random indices counting down from limit."
209209
stop = limit - int(limit * fraction)
210210
iterable = PROGRESS(xrange(limit, stop, -1), 'randindices')
211211
return [random.randrange(length) for length in iterable]
@@ -278,7 +278,7 @@ def benchmark_del(start, limit, times):
278278

279279

280280
def display(name, times, size, last=['', 0]):
281-
'Display performance summary with ratio of ops/sec.'
281+
"Display performance summary with ratio of ops/sec."
282282

283283
times.sort()
284284
median_time = times[len(times) / 2]

Diff for: tests/benchmark_splits_fill.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868

6969
class SortedListWithSplits(sc.SortedList):
70-
'SortedList that counts splits that occur in _expand.'
70+
"SortedList that counts splits that occur in _expand."
7171

7272
def __init__(self, *args, **kwargs):
7373
self.splits = 0
@@ -80,7 +80,7 @@ def _expand(self, pos):
8080

8181

8282
def init_sorted_list(sl, size):
83-
'Initialize a SortedList with normally distributed sublist lengths.'
83+
"Initialize a SortedList with normally distributed sublist lengths."
8484
sl.clear()
8585

8686
total = 0
@@ -105,7 +105,7 @@ def init_sorted_list(sl, size):
105105

106106

107107
def fill(obj, count, limit):
108-
'Repeatedly add random values to the SortedList.'
108+
"Repeatedly add random values to the SortedList."
109109
for each in range(count):
110110
obj.add(random.randrange(limit))
111111

Diff for: tests/plot_lengths_histogram_add.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242

4343

4444
def background():
45-
'Plot the background of each animated frame.'
45+
"Plot the background of each animated frame."
4646
hist_line.set_data([], [])
4747
norm_line.set_data([], [])
4848
return hist_line, norm_line
4949

5050

5151
def frame(num):
52-
'Draw frame.'
52+
"Draw frame."
5353
values.update(func() for func in it.repeat(random.random, LOAD))
5454
data = np.array([len(sublist) for sublist in values._lists])
5555
hist, bins = np.histogram(data, bins=BINS, normed=True)

Diff for: tests/plot_lengths_histogram_delitem.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515

1616

1717
def background():
18-
'Plot the background of each animated frame.'
18+
"Plot the background of each animated frame."
1919
hist_line.set_data([], [])
2020
norm_line.set_data([], [])
2121
return hist_line, norm_line
2222

2323

2424
def frame(num):
25-
'Draw frame.'
25+
"Draw frame."
2626
for value in xrange(LOAD):
2727
del values[random.randrange(len(values))]
2828
data = np.array([len(sublist) for sublist in values._lists])

Diff for: tests/sortedcollection.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -132,69 +132,69 @@ def __contains__(self, item):
132132
return item in self._items[i:j]
133133

134134
def index(self, item):
135-
'Find the position of an item. Raise ValueError if not found.'
135+
"Find the position of an item. Raise ValueError if not found."
136136
k = self._key(item)
137137
i = bisect_left(self._keys, k)
138138
j = bisect_right(self._keys, k)
139139
return self._items[i:j].index(item) + i
140140

141141
def count(self, item):
142-
'Return number of occurrences of item'
142+
"Return number of occurrences of item"
143143
k = self._key(item)
144144
i = bisect_left(self._keys, k)
145145
j = bisect_right(self._keys, k)
146146
return self._items[i:j].count(item)
147147

148148
def insert(self, item):
149-
'Insert a new item. If equal keys are found, add to the left'
149+
"Insert a new item. If equal keys are found, add to the left"
150150
k = self._key(item)
151151
i = bisect_left(self._keys, k)
152152
self._keys.insert(i, k)
153153
self._items.insert(i, item)
154154

155155
def insert_right(self, item):
156-
'Insert a new item. If equal keys are found, add to the right'
156+
"Insert a new item. If equal keys are found, add to the right"
157157
k = self._key(item)
158158
i = bisect_right(self._keys, k)
159159
self._keys.insert(i, k)
160160
self._items.insert(i, item)
161161

162162
def remove(self, item):
163-
'Remove first occurrence of item. Raise ValueError if not found'
163+
"Remove first occurrence of item. Raise ValueError if not found"
164164
i = self.index(item)
165165
del self._keys[i]
166166
del self._items[i]
167167

168168
def find(self, k):
169-
'Return first item with a key == k. Raise ValueError if not found.'
169+
"Return first item with a key == k. Raise ValueError if not found."
170170
i = bisect_left(self._keys, k)
171171
if i != len(self) and self._keys[i] == k:
172172
return self._items[i]
173173
raise ValueError(f'No item found with key equal to: {k!r}')
174174

175175
def find_le(self, k):
176-
'Return last item with a key <= k. Raise ValueError if not found.'
176+
"Return last item with a key <= k. Raise ValueError if not found."
177177
i = bisect_right(self._keys, k)
178178
if i:
179179
return self._items[i - 1]
180180
raise ValueError(f'No item found with key at or below: {k!r}')
181181

182182
def find_lt(self, k):
183-
'Return last item with a key < k. Raise ValueError if not found.'
183+
"Return last item with a key < k. Raise ValueError if not found."
184184
i = bisect_left(self._keys, k)
185185
if i:
186186
return self._items[i - 1]
187187
raise ValueError(f'No item found with key below: {k!r}')
188188

189189
def find_ge(self, k):
190-
'Return first item with a key >= equal to k. Raise ValueError if not found'
190+
"Return first item with a key >= equal to k. Raise ValueError if not found"
191191
i = bisect_left(self._keys, k)
192192
if i != len(self):
193193
return self._items[i]
194194
raise ValueError(f'No item found with key at or above: {k!r}')
195195

196196
def find_gt(self, k):
197-
'Return first item with a key > k. Raise ValueError if not found'
197+
"Return first item with a key > k. Raise ValueError if not found"
198198
i = bisect_right(self._keys, k)
199199
if i != len(self):
200200
return self._items[i]
@@ -232,49 +232,49 @@ def __delitem__(self, index):
232232
if __name__ == '__main__':
233233

234234
def ve2no(f, *args):
235-
'Convert ValueError result to -1'
235+
"Convert ValueError result to -1"
236236
try:
237237
return f(*args)
238238
except ValueError:
239239
return -1
240240

241241
def slow_index(seq, k):
242-
'Location of match or -1 if not found'
242+
"Location of match or -1 if not found"
243243
for i, item in enumerate(seq):
244244
if item == k:
245245
return i
246246
return -1
247247

248248
def slow_find(seq, k):
249-
'First item with a key equal to k. -1 if not found'
249+
"First item with a key equal to k. -1 if not found"
250250
for item in seq:
251251
if item == k:
252252
return item
253253
return -1
254254

255255
def slow_find_le(seq, k):
256-
'Last item with a key less-than or equal to k.'
256+
"Last item with a key less-than or equal to k."
257257
for item in reversed(seq):
258258
if item <= k:
259259
return item
260260
return -1
261261

262262
def slow_find_lt(seq, k):
263-
'Last item with a key less-than k.'
263+
"Last item with a key less-than k."
264264
for item in reversed(seq):
265265
if item < k:
266266
return item
267267
return -1
268268

269269
def slow_find_ge(seq, k):
270-
'First item with a key-value greater-than or equal to k.'
270+
"First item with a key-value greater-than or equal to k."
271271
for item in seq:
272272
if item >= k:
273273
return item
274274
return -1
275275

276276
def slow_find_gt(seq, k):
277-
'First item with a key-value greater-than or equal to k.'
277+
"First item with a key-value greater-than or equal to k."
278278
for item in seq:
279279
if item > k:
280280
return item

Diff for: tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ deps=ruff
3131
[testenv:ruffformatcheck]
3232
commands=ruff format --check {toxinidir}
3333
deps=ruff
34+
skip_install=True
3435

3536
[testenv:doc8]
3637
commands=doc8 docs --ignore-path docs/_build

0 commit comments

Comments
 (0)