Skip to content

Commit f7f85a5

Browse files
hugovksethmlarson
andauthored
Drop support for EOL Python 2.7 and 3.5
Co-authored-by: Seth Michael Larson <[email protected]>
1 parent ec4dc36 commit f7f85a5

Some content is hidden

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

44 files changed

+223
-312
lines changed

.github/workflows/ci.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ jobs:
6060
strategy:
6161
fail-fast: false
6262
matrix:
63-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
63+
python-version: [
64+
"3.6",
65+
"3.7",
66+
"3.8",
67+
"3.9",
68+
]
6469
es-version: [7.0.0, 7.10.0]
6570

6671
steps:

docs/conf.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Licensed to Elasticsearch B.V. under one or more contributor
32
# license agreements. See the NOTICE file distributed with
43
# this work for additional information regarding copyright
@@ -62,8 +61,8 @@
6261
master_doc = "index"
6362

6463
# General information about the project.
65-
project = u"Elasticsearch DSL"
66-
copyright = u"%d, Elasticsearch B.V" % datetime.datetime.now().year
64+
project = "Elasticsearch DSL"
65+
copyright = "%d, Elasticsearch B.V" % datetime.datetime.now().year
6766

6867
# The version info for the project you're documenting, acts as replacement for
6968
# |version| and |release|, also used in various other places throughout the
@@ -216,8 +215,8 @@
216215
(
217216
"index",
218217
"Elasticsearch-dsl.tex",
219-
u"Elasticsearch DSL Documentation",
220-
u"Elasticsearch B.V",
218+
"Elasticsearch DSL Documentation",
219+
"Elasticsearch B.V",
221220
"manual",
222221
),
223222
]
@@ -251,8 +250,8 @@
251250
(
252251
"index",
253252
"elasticsearch-dsl",
254-
u"Elasticsearch DSL Documentation",
255-
[u"Elasticsearch B.V"],
253+
"Elasticsearch DSL Documentation",
254+
["Elasticsearch B.V"],
256255
1,
257256
)
258257
]
@@ -270,8 +269,8 @@
270269
(
271270
"index",
272271
"Elasticsearch",
273-
u"Elasticsearch Documentation",
274-
u"Elasticsearch B.V",
272+
"Elasticsearch Documentation",
273+
"Elasticsearch B.V",
275274
"Elasticsearch",
276275
"One line description of project.",
277276
"Miscellaneous",

elasticsearch_dsl/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
from .utils import AttrDict, AttrList, DslBase
8585
from .wrappers import Range
8686

87-
VERSION = (7, 2, 0)
87+
VERSION = (8, 0, 0)
8888
__version__ = VERSION
8989
__versionstr__ = ".".join(map(str, VERSION))
9090
__all__ = [

elasticsearch_dsl/aggs.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
try:
19-
import collections.abc as collections_abc # only works on python 3.3+
20-
except ImportError:
21-
import collections as collections_abc
18+
import collections.abc
2219

2320
from .response.aggs import AggResponse, BucketData, FieldBucketData, TopHitsData
2421
from .utils import DslBase
@@ -34,7 +31,7 @@ def A(name_or_agg, filter=None, **params):
3431
params["filter"] = filter
3532

3633
# {"terms": {"field": "tags"}, "aggs": {...}}
37-
if isinstance(name_or_agg, collections_abc.Mapping):
34+
if isinstance(name_or_agg, collections.abc.Mapping):
3835
if params:
3936
raise ValueError("A() cannot accept parameters when passing in a dict.")
4037
# copy to avoid modifying in-place
@@ -79,7 +76,7 @@ def __contains__(self, key):
7976
return False
8077

8178
def to_dict(self):
82-
d = super(Agg, self).to_dict()
79+
d = super().to_dict()
8380
if "meta" in d[self.name]:
8481
d["meta"] = d[self.name].pop("meta")
8582
return d
@@ -88,7 +85,7 @@ def result(self, search, data):
8885
return AggResponse(self, search, data)
8986

9087

91-
class AggBase(object):
88+
class AggBase:
9289
_param_defs = {
9390
"aggs": {"type": "agg", "hash": True},
9491
}
@@ -139,7 +136,7 @@ def result(self, search, data):
139136

140137
class Bucket(AggBase, Agg):
141138
def __init__(self, **params):
142-
super(Bucket, self).__init__(**params)
139+
super().__init__(**params)
143140
# remember self for chaining
144141
self._base = self
145142

@@ -160,10 +157,10 @@ class Filter(Bucket):
160157
def __init__(self, filter=None, **params):
161158
if filter is not None:
162159
params["filter"] = filter
163-
super(Filter, self).__init__(**params)
160+
super().__init__(**params)
164161

165162
def to_dict(self):
166-
d = super(Filter, self).to_dict()
163+
d = super().to_dict()
167164
d[self.name].update(d[self.name].pop("filter", {}))
168165
return d
169166

elasticsearch_dsl/analysis.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
import six
19-
2018
from .connections import get_connection
2119
from .utils import AttrDict, DslBase, merge
2220

2321
__all__ = ["tokenizer", "analyzer", "char_filter", "token_filter", "normalizer"]
2422

2523

26-
class AnalysisBase(object):
24+
class AnalysisBase:
2725
@classmethod
2826
def _type_shortcut(cls, name_or_instance, type=None, **kwargs):
2927
if isinstance(name_or_instance, cls):
3028
if type or kwargs:
31-
raise ValueError("%s() cannot accept parameters." % cls.__name__)
29+
raise ValueError(f"{cls.__name__}() cannot accept parameters.")
3230
return name_or_instance
3331

3432
if not (type or kwargs):
@@ -39,20 +37,20 @@ def _type_shortcut(cls, name_or_instance, type=None, **kwargs):
3937
)
4038

4139

42-
class CustomAnalysis(object):
40+
class CustomAnalysis:
4341
name = "custom"
4442

4543
def __init__(self, filter_name, builtin_type="custom", **kwargs):
4644
self._builtin_type = builtin_type
4745
self._name = filter_name
48-
super(CustomAnalysis, self).__init__(**kwargs)
46+
super().__init__(**kwargs)
4947

5048
def to_dict(self):
5149
# only name to present in lists
5250
return self._name
5351

5452
def get_definition(self):
55-
d = super(CustomAnalysis, self).to_dict()
53+
d = super().to_dict()
5654
d = d.pop(self.name)
5755
d["type"] = self._builtin_type
5856
return d
@@ -92,12 +90,12 @@ def get_analysis_definition(self):
9290
return out
9391

9492

95-
class BuiltinAnalysis(object):
93+
class BuiltinAnalysis:
9694
name = "builtin"
9795

9896
def __init__(self, name):
9997
self._name = name
100-
super(BuiltinAnalysis, self).__init__()
98+
super().__init__()
10199

102100
def to_dict(self):
103101
# only name to present in lists
@@ -148,7 +146,7 @@ def simulate(self, text, using="default", explain=False, attributes=None):
148146
sec_def = definition.get(section, {})
149147
sec_names = analyzer_def[section]
150148

151-
if isinstance(sec_names, six.string_types):
149+
if isinstance(sec_names, str):
152150
body[section] = sec_def.get(sec_names, sec_names)
153151
else:
154152
body[section] = [
@@ -213,7 +211,7 @@ def get_definition(self):
213211
if "filters" in d:
214212
d["filters"] = [
215213
# comma delimited string given by user
216-
fs if isinstance(fs, six.string_types) else
214+
fs if isinstance(fs, str) else
217215
# list of strings or TokenFilter objects
218216
", ".join(f.to_dict() if hasattr(f, "to_dict") else f for f in fs)
219217
for fs in self.filters
@@ -227,7 +225,7 @@ def get_analysis_definition(self):
227225
fs = {}
228226
d = {"filter": fs}
229227
for filters in self.filters:
230-
if isinstance(filters, six.string_types):
228+
if isinstance(filters, str):
231229
continue
232230
fs.update(
233231
{

elasticsearch_dsl/connections.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
# under the License.
1717

1818
from elasticsearch import Elasticsearch
19-
from six import string_types
2019

2120
from .serializer import serializer
2221

2322

24-
class Connections(object):
23+
class Connections:
2524
"""
2625
Class responsible for holding connections to different clusters. Used as a
2726
singleton in this module.
@@ -73,7 +72,7 @@ def remove_connection(self, alias):
7372
errors += 1
7473

7574
if errors == 2:
76-
raise KeyError("There is no connection with alias %r." % alias)
75+
raise KeyError(f"There is no connection with alias {alias!r}.")
7776

7877
def create_connection(self, alias="default", **kwargs):
7978
"""
@@ -95,7 +94,7 @@ def get_connection(self, alias="default"):
9594
"""
9695
# do not check isinstance(Elasticsearch) so that people can wrap their
9796
# clients
98-
if not isinstance(alias, string_types):
97+
if not isinstance(alias, str):
9998
return alias
10099

101100
# connection already established
@@ -109,7 +108,7 @@ def get_connection(self, alias="default"):
109108
return self.create_connection(alias, **self._kwargs[alias])
110109
except KeyError:
111110
# no connection and no kwargs to set one up
112-
raise KeyError("There is no connection with alias %r." % alias)
111+
raise KeyError(f"There is no connection with alias {alias!r}.")
113112

114113

115114
connections = Connections()

0 commit comments

Comments
 (0)