1+ from __future__ import annotations
2+
13from collections .abc import Callable , Iterable
4+ from typing import Self
25
36from java .lang import Double , Integer , Long
47from java .util import Arrays
@@ -20,12 +23,12 @@ def __init__(self, base: search.Query, *args):
2023 base .__init__ (self , * args )
2124
2225 @classmethod
23- def term (cls , name : str , value ) -> 'Query' :
26+ def term (cls , name : str , value ) -> Self :
2427 """Return lucene TermQuery."""
2528 return cls (search .TermQuery , index .Term (name , value ))
2629
2730 @classmethod
28- def terms (cls , name : str , values ) -> 'Query' :
31+ def terms (cls , name : str , values ) -> Self :
2932 """Return lucene TermInSetQuery, optimizing a SHOULD BooleanQuery of many terms."""
3033 return cls (search .TermInSetQuery , name , Arrays .asList (list (map (util .BytesRef , values ))))
3134
@@ -65,14 +68,14 @@ def disjunct(cls, multiplier, *queries, **terms):
6568 return cls (search .DisjunctionMaxQuery , Arrays .asList (queries ), multiplier )
6669
6770 @classmethod
68- def span (cls , * term ) -> ' SpanQuery' :
71+ def span (cls , * term ) -> SpanQuery :
6972 """Return [SpanQuery][lupyne.engine.queries.SpanQuery] from term name and value or a MultiTermQuery."""
7073 if len (term ) <= 1 :
7174 return SpanQuery (spans .SpanMultiTermQueryWrapper , * term )
7275 return SpanQuery (spans .SpanTermQuery , index .Term (* term ))
7376
7477 @classmethod
75- def near (cls , name : str , * values , ** kwargs ) -> ' SpanQuery' :
78+ def near (cls , name : str , * values , ** kwargs ) -> SpanQuery :
7679 """Return [SpanNearQuery][lupyne.engine.queries.SpanQuery.near] from terms.
7780 Term values which supply another field name will be masked."""
7881 spans = (
@@ -82,12 +85,12 @@ def near(cls, name: str, *values, **kwargs) -> 'SpanQuery':
8285 return SpanQuery .near (* spans , ** kwargs )
8386
8487 @classmethod
85- def prefix (cls , name : str , value ) -> 'Query' :
88+ def prefix (cls , name : str , value ) -> Self :
8689 """Return lucene PrefixQuery."""
8790 return cls (search .PrefixQuery , index .Term (name , value ))
8891
8992 @classmethod
90- def range (cls , name : str , start , stop , lower = True , upper = False ) -> 'Query' :
93+ def range (cls , name : str , start , stop , lower = True , upper = False ) -> Self :
9194 """Return lucene RangeQuery, by default with a half-open interval."""
9295 start , stop = (value if value is None else util .BytesRef (value ) for value in (start , stop ))
9396 return cls (search .TermRangeQuery , name , start , stop , lower , upper )
@@ -106,27 +109,27 @@ def phrase(cls, name: str, *values, **attrs) -> search.MultiPhraseQuery:
106109 return builder .build ()
107110
108111 @classmethod
109- def wildcard (cls , name : str , value ) -> 'Query' :
112+ def wildcard (cls , name : str , value ) -> Self :
110113 """Return lucene WildcardQuery."""
111114 return cls (search .WildcardQuery , index .Term (name , value ))
112115
113116 @classmethod
114- def fuzzy (cls , name : str , value , * args ) -> 'Query' :
117+ def fuzzy (cls , name : str , value , * args ) -> Self :
115118 """Return lucene FuzzyQuery."""
116119 return cls (search .FuzzyQuery , index .Term (name , value ), * args )
117120
118121 @classmethod
119- def alldocs (cls ) -> 'Query' :
122+ def alldocs (cls ) -> Self :
120123 """Return lucene MatchAllDocsQuery."""
121124 return cls (search .MatchAllDocsQuery )
122125
123126 @classmethod
124- def nodocs (cls ) -> 'Query' :
127+ def nodocs (cls ) -> Self :
125128 """Return lucene MatchNoDocsQuery."""
126129 return cls (search .MatchNoDocsQuery )
127130
128131 @classmethod
129- def regexp (cls , name : str , value , * args ) -> 'Query' :
132+ def regexp (cls , name : str , value , * args ) -> Self :
130133 """Return lucene RegexpQuery."""
131134 return cls (search .RegexpQuery , index .Term (name , value ), * args )
132135
@@ -166,11 +169,11 @@ def ranges(name: str, *intervals, lower=True, upper=False) -> search.Query:
166169 return document .DoublePoint .newRangeQuery (name , starts , stops )
167170 return document .LongPoint .newRangeQuery (name , starts , stops )
168171
169- def constant (self ) -> ' Query' :
172+ def constant (self ) -> Query :
170173 """Return lucene ConstantScoreQuery."""
171174 return Query (search .ConstantScoreQuery , self )
172175
173- def boost (self , value : float ) -> ' Query' :
176+ def boost (self , value : float ) -> Query :
174177 """Return lucene BoostQuery."""
175178 return Query (search .BoostQuery , self , value )
176179
@@ -210,30 +213,30 @@ def __rsub__(self, other):
210213class SpanQuery (Query ):
211214 """Inherited lucene SpanQuery with additional span constructors."""
212215
213- def __getitem__ (self , slc : slice ) -> ' SpanQuery' :
216+ def __getitem__ (self , slc : slice ) -> SpanQuery :
214217 start , stop , step = slc .indices (Integer .MAX_VALUE )
215218 assert step == 1 , 'slice step is not supported'
216219 return SpanQuery (spans .SpanPositionRangeQuery , self , start , stop )
217220
218- def __sub__ (self , other : spans .SpanQuery ) -> ' SpanQuery' :
221+ def __sub__ (self , other : spans .SpanQuery ) -> SpanQuery :
219222 return SpanQuery (spans .SpanNotQuery , self , other )
220223
221- def __or__ (* spans_ : spans .SpanQuery ) -> ' SpanQuery' :
224+ def __or__ (* spans_ : spans .SpanQuery ) -> SpanQuery :
222225 return SpanQuery (spans .SpanOrQuery , spans_ )
223226
224227 def near (* spans_ , slop = 0 , inOrder = True ): # type: ignore
225228 """Return lucene SpanNearQuery from SpanQueries."""
226229 return SpanQuery (spans .SpanNearQuery , spans_ , slop , inOrder )
227230
228- def mask (self , name : str ) -> ' SpanQuery' :
231+ def mask (self , name : str ) -> SpanQuery :
229232 """Return lucene FieldMaskingSpanQuery, which allows combining span queries from different fields."""
230233 return SpanQuery (spans .FieldMaskingSpanQuery , self , name )
231234
232- def containing (self , other : spans .SpanQuery ) -> ' SpanQuery' :
235+ def containing (self , other : spans .SpanQuery ) -> SpanQuery :
233236 """Return lucene SpanContainingQuery."""
234237 return SpanQuery (spans .SpanContainingQuery , self , other )
235238
236- def within (self , other : spans .SpanQuery ) -> ' SpanQuery' :
239+ def within (self , other : spans .SpanQuery ) -> SpanQuery :
237240 """Return lucene SpanWithinQuery."""
238241 return SpanQuery (spans .SpanWithinQuery , self , other )
239242
0 commit comments