Skip to content

Commit 96613cd

Browse files
committed
Require python >=3.11.
1 parent 460b3d4 commit 96613cd

6 files changed

Lines changed: 36 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
55

66
## Unreleased
7+
### Changed
8+
* Python >=3.11 required
79

810
## [3.3.1](https://pypi.org/project/lupyne/3.3.1/) - 2025-11-02
911
### Changed

lupyne/engine/analyzers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections.abc import Callable, Iterable, Mapping
2+
from typing import Self
23

34
from java.io import StringReader
45
from java.lang import Float
@@ -102,12 +103,12 @@ def __init__(self, tokenizer: Callable, *filters: Callable):
102103
self.tokenizer, self.filters = tokenizer, filters
103104

104105
@classmethod
105-
def standard(cls, *filters: Callable) -> 'Analyzer':
106+
def standard(cls, *filters: Callable) -> Self:
106107
"""Return equivalent of StandardAnalyzer with additional filters."""
107108
return cls(analysis.standard.StandardTokenizer, analysis.LowerCaseFilter, *filters)
108109

109110
@classmethod
110-
def whitespace(cls, *filters: Callable) -> 'Analyzer':
111+
def whitespace(cls, *filters: Callable) -> Self:
111112
"""Return equivalent of WhitespaceAnalyzer with additional filters."""
112113
return cls(analysis.core.WhitespaceTokenizer, *filters)
113114

lupyne/engine/documents.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import datetime
44
import operator
55
from collections.abc import Callable, Iterator, Sequence
6+
from typing import Self
67

78
import lucene
89
from java.lang import Long
@@ -74,13 +75,13 @@ def __init__(self, name: str, docValuesType='', indexOptions='', dimensions=0, *
7475
@classmethod
7576
def String(
7677
cls, name: str, tokenized=False, omitNorms=True, indexOptions='DOCS', **settings
77-
) -> 'Field':
78+
) -> Self:
7879
"""Return Field with default settings for strings."""
7980
settings.update(tokenized=tokenized, omitNorms=omitNorms, indexOptions=indexOptions)
8081
return cls(name, **settings)
8182

8283
@classmethod
83-
def Text(cls, name: str, indexOptions='DOCS_AND_FREQS_AND_POSITIONS', **settings) -> 'Field':
84+
def Text(cls, name: str, indexOptions='DOCS_AND_FREQS_AND_POSITIONS', **settings) -> Self:
8485
"""Return Field with default settings for text."""
8586
return cls(name, indexOptions=indexOptions, **settings)
8687

@@ -425,12 +426,12 @@ def groupby(
425426
group.scoredocs = group.scoredocs[:docs]
426427
return Groups(self.searcher, groups[:count], len(groups), self.fields)
427428

428-
def filter(self, func: Callable) -> 'Hits':
429+
def filter(self, func: Callable) -> Self:
429430
"""Return [Hits][lupyne.engine.documents.Hits] filtered by function applied to doc ids."""
430431
scoredocs = [scoredoc for scoredoc in self.scoredocs if func(scoredoc.doc)]
431432
return type(self)(self.searcher, scoredocs, fields=self.fields)
432433

433-
def sorted(self, key: Callable, reverse=False) -> 'Hits':
434+
def sorted(self, key: Callable, reverse=False) -> Self:
434435
"""Return [Hits][lupyne.engine.documents.Hits] sorted by key function applied to doc ids."""
435436
scoredocs = sorted(self.scoredocs, key=lambda scoredoc: key(scoredoc.doc), reverse=reverse)
436437
return type(self)(self.searcher, scoredocs, self.count, self.fields)

lupyne/engine/indexers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections.abc import Iterator, Mapping
66
from functools import partial
77
from pathlib import Path
8+
from typing import Self
89

910
import lucene
1011
from java.io import File, IOException, StringReader
@@ -330,7 +331,7 @@ def __del__(self):
330331
def openIfChanged(self):
331332
return index.DirectoryReader.openIfChanged(index.DirectoryReader.cast_(self.indexReader))
332333

333-
def reopen(self) -> 'IndexSearcher':
334+
def reopen(self) -> Self:
334335
"""Return current [IndexSearcher][lupyne.engine.indexers.IndexSearcher].
335336
336337
Only creates a new one if necessary.

lupyne/engine/queries.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
from __future__ import annotations
2+
13
from collections.abc import Callable, Iterable
4+
from typing import Self
25

36
from java.lang import Double, Integer, Long
47
from 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):
210213
class 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

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "lupyne"
33
version = "3.3.1"
44
description = "Pythonic search engine based on PyLucene."
55
readme = "README.md"
6-
requires-python = ">=3.10"
6+
requires-python = ">=3.11"
77
license = "Apache-2.0"
88
authors = [{name = "Aric Coady", email = "aric.coady@gmail.com"}]
99
keywords = ["lucene", "pylucene"]
@@ -12,11 +12,11 @@ classifiers = [
1212
"Intended Audience :: Developers",
1313
"Operating System :: OS Independent",
1414
"Programming Language :: Python :: 3",
15-
"Programming Language :: Python :: 3.10",
1615
"Programming Language :: Python :: 3.11",
1716
"Programming Language :: Python :: 3.12",
1817
"Programming Language :: Python :: 3.13",
1918
"Programming Language :: Python :: 3.14",
19+
"Programming Language :: Python :: 3.15",
2020
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
2121
"Topic :: Internet :: WWW/HTTP :: Indexing/Search",
2222
"Topic :: Software Development :: Libraries :: Python Modules",

0 commit comments

Comments
 (0)