Skip to content

Commit

Permalink
Merge branch 'main' into more-ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Feb 9, 2024
2 parents 68bdd10 + 4074baf commit db5eda2
Show file tree
Hide file tree
Showing 56 changed files with 256 additions and 85 deletions.
40 changes: 40 additions & 0 deletions .codiumai.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#.codiumai.toml
[tests]

## Testing framework to use - this can affect the content of the generated tests
## as well as the test run command.
## Possible values are:
## Python: Pytest, Unittest
framework = "Pytest"

## A hint to the test generator about whether to use mocks or not. Possible values are true or false.
# use_mocks = false

## How many tests should be generated by default. Fewer tests is faster.
## Does not apply at the moment to extend-suite tests.
num_desired_tests = 20

## A multiline string, delimited with triple-quotes (""") serving as an extra instruction
## that the AI model will take into consideration.
## This will appear as "General instructions" in the
## configuration section in the tests panel.
# plan_instructions = """
# Each line should have a comment explaining it.
# Each comment should start with the comment number (1., 2. etc.)
# """

## A multiline string, delimited with triple-quotes (""") serving as an example test that represents
## what you would like the generated tests to look like in terms of style, setup, etc.
# example_test = """
# describe("something", () => {
# it("says 'bar'", () => {
# // given
#
# // when
# const res = something.say();
#
# // Then
# expect(res).to.equal("bar");
# });
# });
# """
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ eggs/
/test.py
/.vscode/settings.json
/.coverage
/whoosh-reloaded.code-workspace
/.vscode/launch.json
*.coverage.DESKTOP-*
/coverage.xml
/lcov.info
/.codiumai.local.toml
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-merge-conflict
Expand Down
2 changes: 1 addition & 1 deletion benchmark/dictionary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gzip
import os.path
import os

from whoosh import analysis, fields
from whoosh.support.bench import Bench, Spec
Expand Down
1 change: 0 additions & 1 deletion benchmark/marc21.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re

from whoosh import analysis, fields, index, qparser, query, scoring
from whoosh.compat import range
from whoosh.util import now

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion scripts/make_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from datetime import datetime

from whoosh import fields, index
from whoosh.compat import range, u
from whoosh.compat import u

if len(sys.argv) < 2:
print("USAGE: make_checkpoint.py <dir>")
Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ addopts = -rs --tb=short
norecursedirs = .hg .tox _build tmp* env* benchmark stress
minversion = 3.0
python_files = test_*.py

[tool.coverage.run]
source = ["src/whoosh"]

[tool.pytest.ini_options]
addopts = "--cov --cov-report=lcov:lcov.info --cov-report=term"
2 changes: 1 addition & 1 deletion src/whoosh/analysis/intraword.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from collections import deque

from whoosh.analysis.filters import Filter
from whoosh.compat import range, text_type, u
from whoosh.compat import text_type, u


class CompoundWordFilter(Filter):
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/analysis/ngrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from whoosh.analysis.acore import Token
from whoosh.analysis.filters import Filter, LowercaseFilter
from whoosh.analysis.tokenizers import RegexTokenizer, Tokenizer
from whoosh.compat import range, text_type
from whoosh.compat import text_type

# Tokenizer

Expand Down
12 changes: 6 additions & 6 deletions src/whoosh/automata/fsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from bisect import bisect_left

from whoosh.compat import iteritems, next, range, text_type, unichr
from whoosh.compat import iteritems, next, text_type, unichr

unull = unichr(0)

Expand Down Expand Up @@ -122,7 +122,7 @@ def dump(self, stream=sys.stdout):
xs = self.transitions[src]
for label in xs:
dests = xs[label]
end = "||" if self.is_final(dests) else ""
_ = "||" if self.is_final(dests) else ""

def start(self):
return frozenset(self._expand({self.initial}))
Expand Down Expand Up @@ -230,7 +230,7 @@ def dump(self, stream=sys.stdout):
xs = self.transitions[src]
for label in sorted(xs):
dest = xs[label]
end = "||" if self.is_final(dest) else ""
_ = "||" if self.is_final(dest) else ""

def start(self):
return self.initial
Expand Down Expand Up @@ -446,7 +446,7 @@ def u_to_utf8(dfa, base=0):
if label is EPSILON:
continue
elif label is ANY:
raise Exception
raise ValueError
else:
assert isinstance(label, text_type)
label8 = label.encode("utf8")
Expand Down Expand Up @@ -652,9 +652,9 @@ def strings_dfa(strings):

for string in strings:
if string <= last:
raise Exception("Strings must be in order")
raise ValueError("Strings must be in order")
if not string:
raise Exception("Can't add empty string")
raise ValueError("Can't add empty string")

# Find the common prefix with the previous string
i = 0
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/automata/fst.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def write(dbfile, v):
def read(self, dbfile):
typecode = u(dbfile.read(1))
length = dbfile.read_int()
return dbfile.read_array(self.typecode, length)
return dbfile.read_array(typecode, length)

def skip(self, dbfile):
length = dbfile.read_int()
Expand Down
1 change: 0 additions & 1 deletion src/whoosh/automata/lev.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from whoosh.automata.fsa import ANY, EPSILON, NFA
from whoosh.compat import range


def levenshtein_automaton(term, k, prefix=0):
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from collections import defaultdict
from math import log

from whoosh.compat import iteritems, range
from whoosh.compat import iteritems

# Expansion models

Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/codec/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from whoosh import columns
from whoosh.automata import lev
from whoosh.compat import abstractmethod, izip, range, unichr
from whoosh.compat import abstractmethod, izip, unichr
from whoosh.filedb.compound import CompoundStorage
from whoosh.system import emptybytes
from whoosh.util import random_name
Expand Down
1 change: 0 additions & 1 deletion src/whoosh/codec/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from threading import Lock

from whoosh.codec import base
from whoosh.compat import range
from whoosh.matching import ListMatcher
from whoosh.reading import SegmentReader, TermInfo, TermNotFound
from whoosh.writing import SegmentWriter
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def collect(self, sub_docnum):
from heapq import heapify, heappush, heapreplace

from whoosh import sorting
from whoosh.compat import abstractmethod, iteritems, itervalues, range
from whoosh.compat import abstractmethod, iteritems, itervalues
from whoosh.searching import Results, TimeLimit
from whoosh.util import now

Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
except ImportError:
zlib = None

from whoosh.compat import BytesIO, array_tobytes, b, bytes_type, dumps, loads, range
from whoosh.compat import BytesIO, array_tobytes, b, bytes_type, dumps, loads
from whoosh.filedb.structfile import StructFile
from whoosh.idsets import BitSet, OnDiskBitSet
from whoosh.system import emptybytes
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/filedb/filetables.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from binascii import crc32
from hashlib import md5 # type: ignore @UnresolvedImport

from whoosh.compat import b, bytes_type, range
from whoosh.compat import b, bytes_type
from whoosh.system import _INT_SIZE, emptybytes
from whoosh.util.numlists import GrowableArray

Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/idsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from array import array
from bisect import bisect_left, bisect_right

from whoosh.compat import izip, izip_longest, next, range
from whoosh.compat import izip, izip_longest, next
from whoosh.util.numeric import bytes_for_bits

# Number of '1' bits in each byte (0-255)
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/lang/morph_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class of Sun's `Minion search engine <https://minion.dev.java.net/>`_.

import re

from whoosh.compat import iteritems, range
from whoosh.compat import iteritems

# Rule exceptions

Expand Down
1 change: 0 additions & 1 deletion src/whoosh/matching/combo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from array import array

from whoosh.compat import range
from whoosh.matching import mcore


Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/multiproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from multiprocessing import Process, Queue, cpu_count

from whoosh.codec import base
from whoosh.compat import pickle, queue, range
from whoosh.compat import pickle, queue
from whoosh.externalsort import imerge
from whoosh.util import random_name
from whoosh.writing import SegmentWriter
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/qparser/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import copy

from whoosh import query
from whoosh.compat import iteritems, range, u
from whoosh.compat import iteritems, u
from whoosh.qparser import syntax
from whoosh.qparser.common import attach
from whoosh.qparser.taggers import FnTagger, RegexTagger
Expand Down
1 change: 0 additions & 1 deletion src/whoosh/query/nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# policies, either expressed or implied, of Matt Chaput.

from whoosh import matching
from whoosh.compat import range
from whoosh.query import qcore
from whoosh.query.wrappers import WrappingQuery

Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from math import ceil

from whoosh import classify, highlight, query, scoring
from whoosh.compat import iteritems, iterkeys, itervalues, range
from whoosh.compat import iteritems, iterkeys, itervalues
from whoosh.idsets import BitSet, DocIdSet
from whoosh.reading import TermNotFound

Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from array import array
from collections import defaultdict

from whoosh.compat import iteritems, izip, range, string_type
from whoosh.compat import iteritems, izip, string_type

# Faceting objects

Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from heapq import heappush, heapreplace

from whoosh import highlight
from whoosh.compat import iteritems, range
from whoosh.compat import iteritems

# Corrector objects

Expand Down
2 changes: 0 additions & 2 deletions src/whoosh/support/base85.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

import struct

from whoosh.compat import range

# Instead of using the character set from the ascii85 algorithm, I put the
# characters in order so that the encoded text sorts properly (my life would be
# a lot easier if they had just done that from the start)
Expand Down
2 changes: 0 additions & 2 deletions src/whoosh/support/levenshtein.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Contains functions implementing edit distance algorithms.
"""

from whoosh.compat import range


def levenshtein(seq1, seq2, limit=None):
"""Returns the Levenshtein edit distance between two strings."""
Expand Down
2 changes: 0 additions & 2 deletions src/whoosh/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
from bisect import insort
from functools import wraps

from whoosh.compat import range

# These must be valid separate characters in CASE-INSENSTIVE filenames
IDCHARS = "0123456789abcdefghijklmnopqrstuvwxyz"

Expand Down
1 change: 0 additions & 1 deletion src/whoosh/util/numlists.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from array import array

from whoosh.compat import range
from whoosh.system import (
emptybytes,
pack_byte,
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/util/varints.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from array import array

from whoosh.compat import array_tobytes, range
from whoosh.compat import array_tobytes

# Varint cache

Expand Down
2 changes: 1 addition & 1 deletion stress/test_bigindex.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random

from whoosh import fields
from whoosh.compat import range, text_type, u
from whoosh.compat import text_type, u
from whoosh.util import now
from whoosh.util.testing import TempIndex

Expand Down
2 changes: 1 addition & 1 deletion stress/test_bigsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime

from whoosh import fields, index, query
from whoosh.compat import range, text_type
from whoosh.compat import text_type
from whoosh.util import now


Expand Down
2 changes: 1 addition & 1 deletion stress/test_bigtable.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from random import randint, shuffle

from nose.tools import assert_equal # type: ignore @UnresolvedImport
from whoosh.compat import iteritems, range
from whoosh.compat import iteritems
from whoosh.filedb.filetables import HashReader, HashWriter
from whoosh.util.testing import TempStorage

Expand Down
Loading

0 comments on commit db5eda2

Please sign in to comment.