Skip to content

Commit 14bfbf2

Browse files
Drop support for Python 3.8 (#3001)
* Drop support for Python 3.8 * more references to 3.8 updated * remove generated DSL files * pyupgrade suggested improvements
1 parent 44cbf67 commit 14bfbf2

File tree

12 files changed

+238
-201
lines changed

12 files changed

+238
-201
lines changed

.buildkite/pipeline.yml

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

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
strategy:
3939
fail-fast: false
4040
matrix:
41-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
41+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
4242
nox-session: [""]
4343
runs-on: ["ubuntu-latest"]
4444

docs/reference/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This page guides you through the installation process of the Python client, show
1111

1212
### Requirements [_requirements]
1313

14-
* [Python](https://www.python.org/) 3.8 or newer
14+
* [Python](https://www.python.org/) 3.9 or newer
1515
* [`pip`](https://pip.pypa.io/en/stable/), installed by default alongside Python
1616

1717

elasticsearch/_otel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def span(
6767
*,
6868
endpoint_id: str | None,
6969
path_parts: Mapping[str, str],
70-
) -> Generator[OpenTelemetrySpan, None, None]:
70+
) -> Generator[OpenTelemetrySpan]:
7171
if not self.enabled or self.tracer is None:
7272
yield OpenTelemetrySpan(None)
7373
return
@@ -88,7 +88,7 @@ def span(
8888
)
8989

9090
@contextlib.contextmanager
91-
def helpers_span(self, span_name: str) -> Generator[OpenTelemetrySpan, None, None]:
91+
def helpers_span(self, span_name: str) -> Generator[OpenTelemetrySpan]:
9292
if not self.enabled or self.tracer is None:
9393
yield OpenTelemetrySpan(None)
9494
return
@@ -101,7 +101,7 @@ def helpers_span(self, span_name: str) -> Generator[OpenTelemetrySpan, None, Non
101101
yield OpenTelemetrySpan(otel_span)
102102

103103
@contextlib.contextmanager
104-
def use_span(self, span: OpenTelemetrySpan) -> Generator[None, None, None]:
104+
def use_span(self, span: OpenTelemetrySpan) -> Generator[None]:
105105
if not self.enabled or self.tracer is None or span.otel_span is None:
106106
yield
107107
return

elasticsearch/dsl/document_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def __init__(self, name: str, bases: Tuple[type, ...], attrs: Dict[str, Any]):
171171
# # ignore attributes
172172
# field10: ClassVar[string] = "a regular class variable"
173173
annotations = attrs.get("__annotations__", {})
174-
fields = set([n for n in attrs if isinstance(attrs[n], Field)])
174+
fields = {n for n in attrs if isinstance(attrs[n], Field)}
175175
fields.update(annotations.keys())
176176
field_defaults = {}
177177
for name in fields:

examples/fastapi-apm/dockerfiles/Dockerfile.app

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8
1+
FROM python:3.9
22

33
EXPOSE 9292
44
WORKDIR /

examples/fastapi-apm/dockerfiles/Dockerfile.ping

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8
1+
FROM python:3.9
22
WORKDIR /
33
RUN python -m pip install \
44
--no-cache \

noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def pytest_argv():
4444
]
4545

4646

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

5151
session.run(*pytest_argv(), *session.posargs)
5252

5353

54-
@nox.session(python=["3.8", "3.13"])
54+
@nox.session(python=["3.9", "3.13"])
5555
def test_otel(session):
5656
session.install(
5757
".[dev]",

pyproject.toml

Lines changed: 1 addition & 2 deletions
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.8"
10+
requires-python = ">=3.9"
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.8",
2524
"Programming Language :: Python :: 3.9",
2625
"Programming Language :: Python :: 3.10",
2726
"Programming Language :: Python :: 3.11",

test_elasticsearch/test_async/test_server/test_helpers.py

Lines changed: 83 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
542542
bulk.append({"value": x})
543543
await async_client.bulk(operations=bulk, refresh=True)
544544

545-
with patch.object(
546-
async_client, "options", return_value=async_client
547-
), patch.object(async_client, "scroll", MockScroll()):
545+
with (
546+
patch.object(async_client, "options", return_value=async_client),
547+
patch.object(async_client, "scroll", MockScroll()),
548+
):
548549
data = [
549550
x
550551
async for x in helpers.async_scan(
@@ -558,9 +559,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
558559
assert len(data) == 3
559560
assert data[-1] == {"scroll_data": 42}
560561

561-
with patch.object(
562-
async_client, "options", return_value=async_client
563-
), patch.object(async_client, "scroll", MockScroll()):
562+
with (
563+
patch.object(async_client, "options", return_value=async_client),
564+
patch.object(async_client, "scroll", MockScroll()),
565+
):
564566
with pytest.raises(ScanError):
565567
data = [
566568
x
@@ -576,9 +578,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
576578
assert data[-1] == {"scroll_data": 42}
577579

578580
async def test_initial_search_error(self, async_client, scan_teardown):
579-
with patch.object(
580-
async_client, "options", return_value=async_client
581-
), patch.object(async_client, "clear_scroll", new_callable=AsyncMock):
581+
with (
582+
patch.object(async_client, "options", return_value=async_client),
583+
patch.object(async_client, "clear_scroll", new_callable=AsyncMock),
584+
):
582585
with patch.object(
583586
async_client,
584587
"search",
@@ -634,15 +637,16 @@ async def test_initial_search_error(self, async_client, scan_teardown):
634637
assert mock_scroll.calls == []
635638

636639
async def test_no_scroll_id_fast_route(self, async_client, scan_teardown):
637-
with patch.object(
638-
async_client, "options", return_value=async_client
639-
), patch.object(async_client, "scroll") as scroll_mock, patch.object(
640-
async_client,
641-
"search",
642-
MockResponse(ObjectApiResponse(body={"no": "_scroll_id"}, meta=None)),
643-
), patch.object(
644-
async_client, "clear_scroll"
645-
) as clear_mock:
640+
with (
641+
patch.object(async_client, "options", return_value=async_client),
642+
patch.object(async_client, "scroll") as scroll_mock,
643+
patch.object(
644+
async_client,
645+
"search",
646+
MockResponse(ObjectApiResponse(body={"no": "_scroll_id"}, meta=None)),
647+
),
648+
patch.object(async_client, "clear_scroll") as clear_mock,
649+
):
646650
data = [
647651
x async for x in helpers.async_scan(async_client, index="test_index")
648652
]
@@ -661,9 +665,10 @@ async def test_logger(
661665
bulk.append({"value": x})
662666
await async_client.bulk(operations=bulk, refresh=True)
663667

664-
with patch.object(
665-
async_client, "options", return_value=async_client
666-
), patch.object(async_client, "scroll", MockScroll()):
668+
with (
669+
patch.object(async_client, "options", return_value=async_client),
670+
patch.object(async_client, "scroll", MockScroll()),
671+
):
667672
_ = [
668673
x
669674
async for x in helpers.async_scan(
@@ -680,9 +685,10 @@ async def test_logger(
680685
]
681686

682687
caplog.clear()
683-
with patch.object(
684-
async_client, "options", return_value=async_client
685-
), patch.object(async_client, "scroll", MockScroll()):
688+
with (
689+
patch.object(async_client, "options", return_value=async_client),
690+
patch.object(async_client, "scroll", MockScroll()),
691+
):
686692
with pytest.raises(ScanError):
687693
_ = [
688694
x
@@ -706,11 +712,12 @@ async def test_clear_scroll(self, async_client, scan_teardown):
706712
bulk.append({"value": x})
707713
await async_client.bulk(operations=bulk, refresh=True)
708714

709-
with patch.object(
710-
async_client, "options", return_value=async_client
711-
), patch.object(
712-
async_client, "clear_scroll", wraps=async_client.clear_scroll
713-
) as spy:
715+
with (
716+
patch.object(async_client, "options", return_value=async_client),
717+
patch.object(
718+
async_client, "clear_scroll", wraps=async_client.clear_scroll
719+
) as spy,
720+
):
714721
_ = [
715722
x
716723
async for x in helpers.async_scan(
@@ -748,20 +755,21 @@ async def test_clear_scroll(self, async_client, scan_teardown):
748755
async def test_scan_auth_kwargs_forwarded(
749756
self, async_client, scan_teardown, kwargs
750757
):
751-
with patch.object(
752-
async_client, "options", return_value=async_client
753-
) as options, patch.object(
754-
async_client,
755-
"search",
756-
return_value=MockResponse(
757-
ObjectApiResponse(
758-
body={
759-
"_scroll_id": "scroll_id",
760-
"_shards": {"successful": 5, "total": 5, "skipped": 0},
761-
"hits": {"hits": [{"search_data": 1}]},
762-
},
763-
meta=None,
764-
)
758+
with (
759+
patch.object(async_client, "options", return_value=async_client) as options,
760+
patch.object(
761+
async_client,
762+
"search",
763+
return_value=MockResponse(
764+
ObjectApiResponse(
765+
body={
766+
"_scroll_id": "scroll_id",
767+
"_shards": {"successful": 5, "total": 5, "skipped": 0},
768+
"hits": {"hits": [{"search_data": 1}]},
769+
},
770+
meta=None,
771+
)
772+
),
765773
),
766774
):
767775
with patch.object(
@@ -801,20 +809,21 @@ async def test_scan_auth_kwargs_forwarded(
801809
async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
802810
self, async_client, scan_teardown
803811
):
804-
with patch.object(
805-
async_client, "options", return_value=async_client
806-
) as options, patch.object(
807-
async_client,
808-
"search",
809-
return_value=MockResponse(
810-
ObjectApiResponse(
811-
body={
812-
"_scroll_id": "scroll_id",
813-
"_shards": {"successful": 5, "total": 5, "skipped": 0},
814-
"hits": {"hits": [{"search_data": 1}]},
815-
},
816-
meta=None,
817-
)
812+
with (
813+
patch.object(async_client, "options", return_value=async_client) as options,
814+
patch.object(
815+
async_client,
816+
"search",
817+
return_value=MockResponse(
818+
ObjectApiResponse(
819+
body={
820+
"_scroll_id": "scroll_id",
821+
"_shards": {"successful": 5, "total": 5, "skipped": 0},
822+
"hits": {"hits": [{"search_data": 1}]},
823+
},
824+
meta=None,
825+
)
826+
),
818827
),
819828
):
820829
with patch.object(
@@ -878,21 +887,23 @@ async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
878887
],
879888
)
880889
async def test_scan_from_keyword_is_aliased(async_client, scan_kwargs):
881-
with patch.object(async_client, "options", return_value=async_client), patch.object(
882-
async_client,
883-
"search",
884-
return_value=MockResponse(
885-
ObjectApiResponse(
886-
body={
887-
"_scroll_id": "dummy_id",
888-
"_shards": {"successful": 5, "total": 5},
889-
"hits": {"hits": []},
890-
},
891-
meta=None,
892-
)
893-
),
894-
) as search_mock, patch.object(
895-
async_client, "clear_scroll", return_value=MockResponse(None)
890+
with (
891+
patch.object(async_client, "options", return_value=async_client),
892+
patch.object(
893+
async_client,
894+
"search",
895+
return_value=MockResponse(
896+
ObjectApiResponse(
897+
body={
898+
"_scroll_id": "dummy_id",
899+
"_shards": {"successful": 5, "total": 5},
900+
"hits": {"hits": []},
901+
},
902+
meta=None,
903+
)
904+
),
905+
) as search_mock,
906+
patch.object(async_client, "clear_scroll", return_value=MockResponse(None)),
896907
):
897908
[
898909
x

0 commit comments

Comments
 (0)