Skip to content

Commit dec4858

Browse files
kloczekpquentin
andauthored
Drop Python 3.7 support (#2561)
Signed-off-by: Tomasz Kłoczko <[email protected]> Co-authored-by: Quentin Pradet <[email protected]>
1 parent 3073f9c commit dec4858

25 files changed

+35
-60
lines changed

Diff for: .buildkite/pipeline.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ steps:
1111
matrix:
1212
setup:
1313
python:
14-
- "3.7"
1514
- "3.8"
1615
- "3.9"
1716
- "3.10"
@@ -24,7 +23,7 @@ steps:
2423
- "test"
2524
adjustments:
2625
- with:
27-
python: "3.7"
26+
python: "3.8"
2827
connection: "urllib3"
2928
nox_session: "test_otel"
3029
- with:

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
26+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
2727
nox-session: [""]
2828
runs-on: ["ubuntu-latest"]
2929

Diff for: docs/guide/getting-started.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ operations with it.
88
[discrete]
99
=== Requirements
1010

11-
* https://www.python.org/[Python] 3.7 or newer
11+
* https://www.python.org/[Python] 3.8 or newer
1212
* https://pip.pypa.io/en/stable/[`pip`], installed by default alongside Python
1313

1414
[discrete]

Diff for: docs/sphinx/conf.py

-1
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

Diff for: docs/sphinx/quickstart.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ operations like indexing or searching documents.
99
Requirements
1010
------------
1111

12-
- `Python <https://www.python.org/>`_ 3.7 or newer
12+
- `Python <https://www.python.org/>`_ 3.8 or newer
1313
- `pip <https://pip.pypa.io/en/stable/>`_
1414

1515

Diff for: elasticsearch/_otel.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919

2020
import contextlib
2121
import os
22-
from typing import TYPE_CHECKING, Generator, Mapping
23-
24-
if TYPE_CHECKING:
25-
from typing import Literal
22+
from typing import Generator, Literal, Mapping
2623

2724
try:
2825
from opentelemetry import trace
@@ -48,8 +45,7 @@ def __init__(
4845
self,
4946
enabled: bool | None = None,
5047
tracer: trace.Tracer | None = None,
51-
# TODO import Literal at the top-level when dropping Python 3.7
52-
body_strategy: 'Literal["omit", "raw"]' | None = None,
48+
body_strategy: Literal["omit", "raw"] | None = None,
5349
):
5450
if enabled is None:
5551
enabled = os.environ.get(ENABLED_ENV_VAR, "true") == "true"

Diff for: examples/bulk-ingest/bulk-ingest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def generate_actions():
6666
yields a single document. This function is passed into the bulk()
6767
helper to create many documents in sequence.
6868
"""
69-
with open(DATASET_PATH, mode="r") as f:
69+
with open(DATASET_PATH) as f:
7070
reader = csv.DictReader(f)
7171

7272
for row in reader:

Diff for: noxfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ def pytest_argv():
4545
]
4646

4747

48-
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"])
48+
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
4949
def test(session):
5050
session.install(".[dev]", env=INSTALL_ENV, silent=False)
5151

5252
session.run(*pytest_argv())
5353

5454

55-
@nox.session(python=["3.7", "3.12"])
55+
@nox.session(python=["3.8", "3.12"])
5656
def test_otel(session):
5757
session.install(
5858
".[dev]",

Diff for: pyproject.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "elasticsearch"
77
description = "Python client for Elasticsearch"
88
readme = "README.md"
99
license = "Apache-2.0"
10-
requires-python = ">=3.7"
10+
requires-python = ">=3.8"
1111
authors = [
1212
{ name = "Elastic Client Library Maintainers", email = "[email protected]" },
1313
]
@@ -21,7 +21,6 @@ classifiers = [
2121
"Operating System :: OS Independent",
2222
"Programming Language :: Python",
2323
"Programming Language :: Python :: 3",
24-
"Programming Language :: Python :: 3.7",
2524
"Programming Language :: Python :: 3.8",
2625
"Programming Language :: Python :: 3.9",
2726
"Programming Language :: Python :: 3.10",
@@ -72,8 +71,6 @@ dev = [
7271
"simsimd",
7372
"pandas",
7473
"mapbox-vector-tile",
75-
# Python 3.7 gets an old version of mapbox-vector-tile, requiring an old version of protobuf
76-
"protobuf<4; python_version<=\"3.7\"",
7774
]
7875
docs = [
7976
"sphinx",

Diff for: test_elasticsearch/test_async/test_server/test_clients.py

-2
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
@@ -16,7 +15,6 @@
1615
# specific language governing permissions and limitations
1716
# under the License.
1817

19-
from __future__ import unicode_literals
2018

2119
import pytest
2220

Diff for: test_elasticsearch/test_async/test_server/test_helpers.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333

3434
class AsyncMock(MagicMock):
3535
async def __call__(self, *args, **kwargs):
36-
return super(AsyncMock, self).__call__(*args, **kwargs)
36+
return super().__call__(*args, **kwargs)
3737

3838
def __await__(self):
3939
return self().__await__()
4040

4141

42-
class FailingBulkClient(object):
42+
class FailingBulkClient:
4343
def __init__(
4444
self,
4545
client,
@@ -68,7 +68,7 @@ def options(self, **_):
6868
return self
6969

7070

71-
class TestStreamingBulk(object):
71+
class TestStreamingBulk:
7272
async def test_actions_remain_unchanged(self, async_client):
7373
actions = [{"_id": 1}, {"_id": 2}]
7474
async for ok, item in helpers.async_streaming_bulk(
@@ -294,7 +294,7 @@ async def streaming_bulk():
294294
assert 4 == failing_client._called
295295

296296

297-
class TestBulk(object):
297+
class TestBulk:
298298
async def test_bulk_works_with_single_item(self, async_client):
299299
docs = [{"answer": 42, "_id": 1}]
300300
success, failed = await helpers.async_bulk(
@@ -458,7 +458,7 @@ async def scan_teardown(async_client):
458458
await async_client.clear_scroll(scroll_id="_all")
459459

460460

461-
class TestScan(object):
461+
class TestScan:
462462
async def test_order_can_be_preserved(self, async_client, scan_teardown):
463463
bulk = []
464464
for x in range(100):
@@ -493,8 +493,8 @@ async def test_all_documents_are_read(self, async_client, scan_teardown):
493493
]
494494

495495
assert 100 == len(docs)
496-
assert set(map(str, range(100))) == set(d["_id"] for d in docs)
497-
assert set(range(100)) == set(d["_source"]["answer"] for d in docs)
496+
assert set(map(str, range(100))) == {d["_id"] for d in docs}
497+
assert set(range(100)) == {d["_source"]["answer"] for d in docs}
498498

499499
async def test_scroll_error(self, async_client, scan_teardown):
500500
bulk = []
@@ -881,7 +881,7 @@ async def reindex_setup(async_client):
881881
yield
882882

883883

884-
class TestReindex(object):
884+
class TestReindex:
885885
async def test_reindex_passes_kwargs_to_scan_and_bulk(
886886
self, async_client, reindex_setup
887887
):
@@ -1031,7 +1031,7 @@ async def reindex_data_stream_setup(async_client):
10311031
yield
10321032

10331033

1034-
class TestAsyncDataStreamReindex(object):
1034+
class TestAsyncDataStreamReindex:
10351035
@pytest.mark.parametrize("op_type", [None, "create"])
10361036
async def test_reindex_index_datastream(
10371037
self, op_type, async_client, reindex_data_stream_setup

Diff for: test_elasticsearch/test_async/test_server/test_rest_api_spec.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ async def _feature_enabled(self, name):
228228
if XPACK_FEATURES is None:
229229
try:
230230
xinfo = await self.client.xpack.info()
231-
XPACK_FEATURES = set(
231+
XPACK_FEATURES = {
232232
f for f in xinfo["features"] if xinfo["features"][f]["enabled"]
233-
)
233+
}
234234
IMPLEMENTED_FEATURES.add("xpack")
235235
except RequestError:
236236
XPACK_FEATURES = set()

Diff for: test_elasticsearch/test_async/test_transport.py

+1-3
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
@@ -16,7 +15,6 @@
1615
# specific language governing permissions and limitations
1716
# under the License.
1817

19-
from __future__ import unicode_literals
2018

2119
import asyncio
2220
import re
@@ -280,7 +278,7 @@ def test_kwargs_passed_on_to_node_pool(self):
280278
)
281279
assert dt is client.transport.node_pool.dead_node_backoff_factor
282280

283-
class MyConnection(object):
281+
class MyConnection:
284282
def __init__(self, *_, **__):
285283
pass
286284

Diff for: test_elasticsearch/test_client/test_options.py

-1
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

Diff for: test_elasticsearch/test_client/test_overrides.py

-1
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

Diff for: test_elasticsearch/test_client/test_utils.py

-2
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
@@ -16,7 +15,6 @@
1615
# specific language governing permissions and limitations
1716
# under the License.
1817

19-
from __future__ import unicode_literals
2018

2119
from elasticsearch._sync.client.utils import _quote
2220

Diff for: test_elasticsearch/test_helpers.py

+1-2
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
@@ -75,7 +74,7 @@ def test_chunk_sent_from_different_threads(self, _process_bulk_chunk):
7574
chunk_size=2,
7675
)
7776
)
78-
assert len(set([r[1] for r in results])) > 1
77+
assert len({r[1] for r in results}) > 1
7978

8079

8180
class TestChunkActions:

Diff for: test_elasticsearch/test_serializer.py

-1
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

Diff for: test_elasticsearch/test_server/test_clients.py

-1
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

Diff for: test_elasticsearch/test_server/test_helpers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from elasticsearch.helpers import ScanError
2828

2929

30-
class FailingBulkClient(object):
30+
class FailingBulkClient:
3131
def __init__(
3232
self,
3333
client,
@@ -463,8 +463,8 @@ def test_all_documents_are_read(sync_client):
463463
docs = list(helpers.scan(sync_client, index="test_index", size=2))
464464

465465
assert 100 == len(docs)
466-
assert set(map(str, range(100))) == set(d["_id"] for d in docs)
467-
assert set(range(100)) == set(d["_source"]["answer"] for d in docs)
466+
assert set(map(str, range(100))) == {d["_id"] for d in docs}
467+
assert set(range(100)) == {d["_source"]["answer"] for d in docs}
468468

469469

470470
@pytest.mark.usefixtures("scan_teardown")

Diff for: test_elasticsearch/test_server/test_rest_api_spec.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import json
2525
import os
2626
import re
27-
import sys
2827
import warnings
2928
import zipfile
3029
from typing import Tuple, Union
@@ -131,10 +130,7 @@
131130

132131
XPACK_FEATURES = None
133132
ES_VERSION = None
134-
RUN_ASYNC_REST_API_TESTS = (
135-
sys.version_info >= (3, 8)
136-
and os.environ.get("PYTHON_CONNECTION_CLASS") == "requests"
137-
)
133+
RUN_ASYNC_REST_API_TESTS = os.environ.get("PYTHON_CONNECTION_CLASS") == "requests"
138134

139135
FALSEY_VALUES = ("", None, False, 0, 0.0)
140136

@@ -456,7 +452,7 @@ def _resolve(self, value):
456452
if isinstance(value, string_types):
457453
value = value.strip()
458454
elif isinstance(value, dict):
459-
value = dict((k, self._resolve(v)) for (k, v) in value.items())
455+
value = {k: self._resolve(v) for (k, v) in value.items()}
460456
elif isinstance(value, list):
461457
value = list(map(self._resolve, value))
462458
return value
@@ -495,9 +491,9 @@ def _feature_enabled(self, name):
495491
if XPACK_FEATURES is None:
496492
try:
497493
xinfo = self.client.xpack.info()
498-
XPACK_FEATURES = set(
494+
XPACK_FEATURES = {
499495
f for f in xinfo["features"] if xinfo["features"][f]["enabled"]
500-
)
496+
}
501497
IMPLEMENTED_FEATURES.add("xpack")
502498
except RequestError:
503499
XPACK_FEATURES = set()

Diff for: test_elasticsearch/test_transport.py

+1-2
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
@@ -311,7 +310,7 @@ def test_kwargs_passed_on_to_node_pool(self):
311310
assert dt is client.transport.node_pool.dead_node_backoff_factor
312311

313312
def test_custom_node_class(self):
314-
class MyConnection(object):
313+
class MyConnection:
315314
def __init__(self, *_, **__):
316315
pass
317316

Diff for: utils/build-dists.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run(*argv, expect_exit_code=0):
5050
else:
5151
os.chdir(tmp_dir)
5252

53-
cmd = " ".join(shlex.quote(x) for x in argv)
53+
cmd = shlex.join(argv)
5454
print("$ " + cmd)
5555
exit_code = os.system(cmd)
5656
if exit_code != expect_exit_code:

Diff for: utils/bump-version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
def find_and_replace(path, pattern, replace):
3030
# Does a find and replace within a file path and complains
3131
# if the given pattern isn't found in the file.
32-
with open(path, "r") as f:
32+
with open(path) as f:
3333
old_data = f.read()
3434

3535
if re.search(pattern, old_data, flags=re.MULTILINE) is None:

Diff for: utils/license-headers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def find_files_to_fix(sources: List[str]) -> Iterator[str]:
6666
def does_file_need_fix(filepath: str) -> bool:
6767
if not re.search(r"\.pyi?$", filepath):
6868
return False
69-
with open(filepath, mode="r") as f:
69+
with open(filepath) as f:
7070
first_license_line = None
7171
for line in f:
7272
if line == license_header_lines[0]:
@@ -83,7 +83,7 @@ def does_file_need_fix(filepath: str) -> bool:
8383

8484

8585
def add_header_to_file(filepath: str) -> None:
86-
with open(filepath, mode="r") as f:
86+
with open(filepath) as f:
8787
lines = list(f)
8888
i = 0
8989
for i, line in enumerate(lines):

0 commit comments

Comments
 (0)