Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the tests that were failing due to circular imports introduced in PR #55 #56

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
rev: v0.2.1
hooks:
- id: ruff
args: [ --select=I ] # isort
args: [ --select=I, --fix] # isort
- id: ruff-format

- repo: https://github.com/asottile/pyupgrade
Expand Down
4 changes: 2 additions & 2 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A quick introduction
::

>>> from whoosh.index import create_in
>>> from whoosh.fields import *
>>> from whoosh.fields import Schema, TEXT, ID
>>> schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT)
>>> ix = create_in("indexdir", schema)
>>> writer = ix.writer()
Expand Down Expand Up @@ -194,7 +194,7 @@ For example, this query would match documents that contain both "apple" and

# Construct query objects directly

from whoosh.query import *
from whoosh.query import And, Term
myquery = And([Term("content", u"apple"), Term("content", "bear")])

To parse a query string, you can use the default query parser in the ``qparser``
Expand Down
64 changes: 57 additions & 7 deletions src/whoosh/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,60 @@
a filter first or a tokenizer after the first item).
"""

from whoosh.analysis.acore import *
from whoosh.analysis.analyzers import *
from whoosh.analysis.filters import *
from whoosh.analysis.intraword import *
from whoosh.analysis.morph import *
from whoosh.analysis.ngrams import *
from whoosh.analysis.tokenizers import *
from whoosh.analysis.acore import (
Composable,
CompositionError,

Check failure on line 65 in src/whoosh/analysis/__init__.py

View workflow job for this annotation

GitHub Actions / codespell_and_ruff

Ruff (F401)

src/whoosh/analysis/__init__.py:65:5: F401 `whoosh.analysis.acore.CompositionError` imported but unused
Token,

Check failure on line 66 in src/whoosh/analysis/__init__.py

View workflow job for this annotation

GitHub Actions / codespell_and_ruff

Ruff (F401)

src/whoosh/analysis/__init__.py:66:5: F401 `whoosh.analysis.acore.Token` imported but unused
entoken,

Check failure on line 67 in src/whoosh/analysis/__init__.py

View workflow job for this annotation

GitHub Actions / codespell_and_ruff

Ruff (F401)

src/whoosh/analysis/__init__.py:67:5: F401 `whoosh.analysis.acore.entoken` imported but unused
unstopped,

Check failure on line 68 in src/whoosh/analysis/__init__.py

View workflow job for this annotation

GitHub Actions / codespell_and_ruff

Ruff (F401)

src/whoosh/analysis/__init__.py:68:5: F401 `whoosh.analysis.acore.unstopped` imported but unused
)
from whoosh.analysis.analyzers import (
Analyzer,
FancyAnalyzer,
IDAnalyzer,
KeywordAnalyzer,
LanguageAnalyzer,
RegexAnalyzer,
SimpleAnalyzer,
StandardAnalyzer,
StemmingAnalyzer,
)
from whoosh.analysis.filters import (
STOP_WORDS,
CharsetFilter,
Composable,
DelimitedAttributeFilter,
Filter,
LoggingFilter,
LowercaseFilter,
MultiFilter,
PassFilter,
ReverseTextFilter,
StopFilter,
StripFilter,
SubstitutionFilter,
TeeFilter,
url_pattern,
)
from whoosh.analysis.intraword import (
BiWordFilter,
CompoundWordFilter,
IntraWordFilter,
ShingleFilter,
)
from whoosh.analysis.morph import DoubleMetaphoneFilter, PyStemmerFilter, StemFilter
from whoosh.analysis.ngrams import (
NgramAnalyzer,
NgramFilter,
NgramTokenizer,
NgramWordAnalyzer,
)
from whoosh.analysis.tokenizers import (
CharsetTokenizer,
CommaSeparatedTokenizer,
IDTokenizer,
PathTokenizer,
RegexTokenizer,
SpaceSeparatedTokenizer,
Tokenizer,
)
39 changes: 35 additions & 4 deletions src/whoosh/matching/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,38 @@
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of Matt Chaput.

from whoosh.matching.binary import *
from whoosh.matching.combo import *
from whoosh.matching.mcore import *
from whoosh.matching.wrappers import *
from whoosh.matching.binary import (
AdditiveBiMatcher,
AndMaybeMatcher,
AndNotMatcher,
BiMatcher,
DisjunctionMaxMatcher,
IntersectionMatcher,
UnionMatcher,
)
from whoosh.matching.combo import (
ArrayUnionMatcher,
CombinationMatcher,
PreloadedUnionMatcher,
)
from whoosh.matching.mcore import (
ConstantScoreMatcher,
LeafMatcher,
ListMatcher,
Matcher,
NoQualityAvailable,
NullMatcher,
NullMatcherClass,
ReadTooFar,
)
from whoosh.matching.wrappers import (
ConstantScoreWrapperMatcher,
CoordMatcher,
ExcludeMatcher,
FilterMatcher,
InverseMatcher,
MultiMatcher,
RequireMatcher,
SingleTermMatcher,
WrappingMatcher,
)
59 changes: 56 additions & 3 deletions src/whoosh/qparser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,59 @@
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of Matt Chaput.

from whoosh.qparser.default import *
from whoosh.qparser.plugins import *
from whoosh.qparser.syntax import *
from whoosh.qparser.default import (
DisMaxParser,
MultifieldParser,
QueryParser,
SimpleParser,
)
from whoosh.qparser.plugins import (
BoostPlugin,
CopyFieldPlugin,
EveryPlugin,
FieldAliasPlugin,
FieldsPlugin,
FunctionPlugin,
FuzzyTermPlugin,
GroupPlugin,
GtLtPlugin,
MultifieldPlugin,
OperatorsPlugin,
PhrasePlugin,
Plugin,
PlusMinusPlugin,
PrefixPlugin,
PseudoFieldPlugin,
RangePlugin,
RegexPlugin,
RegexTagger,
SequencePlugin,
SingleQuotePlugin,
TaggingPlugin,
WhitespacePlugin,
WildcardPlugin,
)
from whoosh.qparser.syntax import (
AndGroup,
AndMaybeGroup,
AndNotGroup,
BinaryGroup,
DisMaxGroup,
ErrorNode,
FieldnameNode,
GroupNode,
InfixOperator,
MarkerNode,
NotGroup,
Operator,
OrderedGroup,
OrGroup,
PostfixOperator,
PrefixOperator,
RequireGroup,
SyntaxNode,
TextNode,
Whitespace,
WordNode,
Wrapper,
)
68 changes: 59 additions & 9 deletions src/whoosh/query/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,62 @@
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of Matt Chaput.

from whoosh.query.compound import *
from whoosh.query.nested import *
from whoosh.query.positional import *
from whoosh.query.qcolumns import *
from whoosh.query.qcore import *
from whoosh.query.ranges import *
from whoosh.query.spans import *
from whoosh.query.terms import *
from whoosh.query.wrappers import *

from whoosh.query.compound import (
And,
AndMaybe,
AndNot,
BinaryQuery,
BooleanQuery,
CompoundQuery,
DefaultOr,
DisjunctionMax,
Or,
Otherwise,
PreloadedOr,
Require,
SplitOr,
)
from whoosh.query.nested import NestedChildren, NestedParent
from whoosh.query.positional import Ordered, Phrase, Sequence
from whoosh.query.qcolumns import ColumnMatcher, ColumnQuery
from whoosh.query.qcore import (
Every,
Highest,
Lowest,
NullQuery,
Query,
QueryError,
_NullQuery,
error_query,
token_lists,
)
from whoosh.query.ranges import DateRange, NumericRange, RangeMixin, TermRange
from whoosh.query.spans import (
Span,
SpanBefore,
SpanBiMatcher,
SpanBiQuery,
SpanCondition,
SpanContains,
SpanFirst,
SpanNear,
SpanNear2,
SpanNot,
SpanOr,
SpanQuery,
SpanWrappingMatcher,
WrappingSpan,
)
from whoosh.query.terms import (
ExpandingTerm,
FuzzyTerm,
MultiTerm,
PatternQuery,
Prefix,
Regex,
Term,
Variations,
Wildcard,
)
from whoosh.query.wrappers import ConstantScoreQuery, Not, WeightingQuery, WrappingQuery
2 changes: 1 addition & 1 deletion src/whoosh/query/qcolumns.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# policies, either expressed or implied, of Matt Chaput.

from whoosh.matching import ConstantScoreMatcher, NullMatcher, ReadTooFar
from whoosh.query import Query
from whoosh.query.qcore import Query


class ColumnQuery(Query):
Expand Down
3 changes: 2 additions & 1 deletion src/whoosh/query/spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"""

from whoosh.matching import binary, mcore, wrappers
from whoosh.query import And, AndMaybe, Or, Query, Term
from whoosh.query.compound import And, AndMaybe, Or
from whoosh.query.qcore import Query
from whoosh.util import make_binary_tree

# Span class
Expand Down
2 changes: 1 addition & 1 deletion src/whoosh/writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def add_document(self, **fields):

from datetime import datetime, timedelta
from whoosh import index
from whoosh.fields import *
from whoosh.fields import Schema, DATETIME, NUMERIC, TEXT

schema = Schema(date=DATETIME, size=NUMERIC(float), content=TEXT)
myindex = index.create_in("indexdir", schema)
Expand Down
10 changes: 9 additions & 1 deletion tests/test_dateparse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from whoosh.qparser.dateparse import *
from datetime import datetime, timedelta

from whoosh.qparser.dateparse import (
English,
adatetime,
relative_days,
relativedelta,
timespan,
)

basedate = datetime(2010, 9, 20, 15, 16, 6, 454000)
english = English()
Expand Down
Loading