Skip to content

Commit 352a260

Browse files
Fixed more tests that were broken after the renaming.
1 parent ce342cf commit 352a260

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+534
-513
lines changed

benchmark/dictionary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def whoosh_schema(self):
3535
return schema
3636

3737
def zcatalog_setup(self, cat):
38-
from zcatalog import indexes # @UnresolvedImport
38+
from zcatalog import indexes # type: ignore @UnresolvedImport
3939

4040
cat["head"] = indexes.FieldIndex(field_name="head")
4141
cat["body"] = indexes.TextIndex(field_name="body")

benchmark/marc21.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import fnmatch, logging, os.path, re
33

44
from whoosh import analysis, fields, index, qparser, query, scoring
5-
from whoosh.compat import xrange
5+
from whoosh.compat import range
66
from whoosh.util import now
77

88

@@ -59,7 +59,7 @@ def parse_record(data, tags=None):
5959
field_count = (dirend - dirstart) // DIRECTORY_ENTRY_LEN
6060

6161
result = {}
62-
for i in xrange(field_count):
62+
for i in range(field_count):
6363
start = dirstart + i * DIRECTORY_ENTRY_LEN
6464
end = start + DIRECTORY_ENTRY_LEN
6565
tag = data[start : start + 3]

benchmark/reuters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def whoosh_schema(self):
2222
return schema
2323

2424
def zcatalog_setup(self, cat):
25-
from zcatalog import indexes # @UnresolvedImport
25+
from zcatalog import indexes # type: ignore @UnresolvedImport
2626

2727
cat["id"] = indexes.FieldIndex(field_name="id")
2828
cat["headline"] = indexes.TextIndex(field_name="headline")

docs/source/facets.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,12 @@ document numbers in the same relative order as in the results. You can use the
386386
return the document's stored fields as a dictionary::
387387

388388
for category_name in categories:
389-
print "Top 5 documents in the %s category" % category_name
389+
print ("Top 5 documents in the %s category") % category_name
390390
doclist = categories[category_name]
391391
for docnum, score in doclist[:5]:
392-
print " ", searcher.stored_fields(docnum)
392+
print (" ", searcher.stored_fields(docnum))
393393
if len(doclist) > 5:
394-
print " (%s more)" % (len(doclist) - 5)
394+
print (" (%s more)") % (len(doclist) - 5)
395395

396396
If you want different information about the groups, for example just the count
397397
of documents in each group, or you don't need the groups to be ordered, you can

scripts/make_checkpoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from datetime import datetime
99

1010
from whoosh import fields, index
11-
from whoosh.compat import u, xrange
11+
from whoosh.compat import u, range
1212

1313

1414
if len(sys.argv) < 2:
@@ -44,7 +44,7 @@
4444
for num in range(100):
4545
frac += 0.15
4646
path = u("%s/%s" % (segnum, num))
47-
title = " ".join(random.choice(words) for _ in xrange(100))
47+
title = " ".join(random.choice(words) for _ in range(100))
4848
dt = datetime(year=2000 + counter, month=(counter % 12) + 1, day=15)
4949

5050
w.add_document(

src/whoosh/analysis/intraword.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from collections import deque
3030

3131
from whoosh.compat import u, text_type
32-
from whoosh.compat import xrange
32+
from whoosh.compat import range
3333
from whoosh.analysis.filters import Filter
3434

3535

@@ -71,7 +71,7 @@ def subwords(self, s, memo):
7171
if s in memo:
7272
return memo[s]
7373

74-
for i in xrange(1, len(s)):
74+
for i in range(1, len(s)):
7575
prefix = s[:i]
7676
if prefix in self.wordset:
7777
suffix = s[i:]

src/whoosh/analysis/morph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ def algorithms(self):
180180
library.
181181
"""
182182

183-
import Stemmer # @UnresolvedImport
183+
import Stemmer # type: ignore @UnresolvedImport
184184

185185
return Stemmer.algorithms()
186186

187187
def cache_info(self):
188188
return None
189189

190190
def _get_stemmer_fn(self):
191-
import Stemmer # @UnresolvedImport
191+
import Stemmer # type: ignore @UnresolvedImport
192192

193193
stemmer = Stemmer.Stemmer(self.lang)
194194
stemmer.maxCacheSize = self.cachesize

src/whoosh/analysis/ngrams.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# policies, either expressed or implied, of Matt Chaput.
2727

2828
from whoosh.compat import text_type
29-
from whoosh.compat import xrange
29+
from whoosh.compat import range
3030
from whoosh.analysis.acore import Token
3131
from whoosh.analysis.filters import Filter, LowercaseFilter
3232
from whoosh.analysis.tokenizers import Tokenizer, RegexTokenizer
@@ -89,7 +89,7 @@ def __call__(
8989

9090
if mode == "query":
9191
size = min(self.max, inlen)
92-
for start in xrange(0, inlen - size + 1):
92+
for start in range(0, inlen - size + 1):
9393
end = start + size
9494
if end > inlen:
9595
continue
@@ -105,8 +105,8 @@ def __call__(
105105
yield t
106106
pos += 1
107107
else:
108-
for start in xrange(0, inlen - self.min + 1):
109-
for size in xrange(self.min, self.max + 1):
108+
for start in range(0, inlen - self.min + 1):
109+
for size in range(self.min, self.max + 1):
110110
end = start + size
111111
if end > inlen:
112112
continue
@@ -193,7 +193,7 @@ def __call__(self, tokens):
193193
t.startchar = t.endchar - size
194194
yield t
195195
else:
196-
for start in xrange(0, len(text) - size + 1):
196+
for start in range(0, len(text) - size + 1):
197197
t.text = text[start : start + size]
198198
if chars:
199199
t.startchar = startchar + start
@@ -202,7 +202,7 @@ def __call__(self, tokens):
202202
else:
203203
if at == -1:
204204
limit = min(self.max, len(text))
205-
for size in xrange(self.min, limit + 1):
205+
for size in range(self.min, limit + 1):
206206
t.text = text[:size]
207207
if chars:
208208
t.endchar = startchar + size
@@ -212,14 +212,14 @@ def __call__(self, tokens):
212212
if chars:
213213
original_startchar = t.startchar
214214
start = max(0, len(text) - self.max)
215-
for i in xrange(start, len(text) - self.min + 1):
215+
for i in range(start, len(text) - self.min + 1):
216216
t.text = text[i:]
217217
if chars:
218218
t.startchar = original_startchar + i
219219
yield t
220220
else:
221-
for start in xrange(0, len(text) - self.min + 1):
222-
for size in xrange(self.min, self.max + 1):
221+
for start in range(0, len(text) - self.min + 1):
222+
for size in range(self.min, self.max + 1):
223223
end = start + size
224224
if end > len(text):
225225
continue

src/whoosh/automata/fsa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66
from bisect import bisect_left
77

8-
from whoosh.compat import iteritems, next, text_type, unichr, xrange
8+
from whoosh.compat import iteritems, next, text_type, unichr, range
99

1010

1111
unull = unichr(0)
@@ -340,7 +340,7 @@ def minimize(self):
340340
parts = [final_states, reachable - final_states]
341341
while changed:
342342
changed = False
343-
for i in xrange(len(parts)):
343+
for i in range(len(parts)):
344344
part = parts[i]
345345
changed_part = False
346346
for label in labels:

0 commit comments

Comments
 (0)