Skip to content

Drop support for Python 3.8 #3001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ steps:
matrix:
setup:
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
Expand All @@ -24,7 +23,7 @@ steps:
- "test"
adjustments:
- with:
python: "3.8"
python: "3.9"
connection: "urllib3"
nox_session: "test_otel"
- with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
nox-session: [""]
runs-on: ["ubuntu-latest"]

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This page guides you through the installation process of the Python client, show

### Requirements [_requirements]

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


Expand Down
6 changes: 3 additions & 3 deletions elasticsearch/_otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def span(
*,
endpoint_id: str | None,
path_parts: Mapping[str, str],
) -> Generator[OpenTelemetrySpan, None, None]:
) -> Generator[OpenTelemetrySpan]:
if not self.enabled or self.tracer is None:
yield OpenTelemetrySpan(None)
return
Expand All @@ -88,7 +88,7 @@ def span(
)

@contextlib.contextmanager
def helpers_span(self, span_name: str) -> Generator[OpenTelemetrySpan, None, None]:
def helpers_span(self, span_name: str) -> Generator[OpenTelemetrySpan]:
if not self.enabled or self.tracer is None:
yield OpenTelemetrySpan(None)
return
Expand All @@ -101,7 +101,7 @@ def helpers_span(self, span_name: str) -> Generator[OpenTelemetrySpan, None, Non
yield OpenTelemetrySpan(otel_span)

@contextlib.contextmanager
def use_span(self, span: OpenTelemetrySpan) -> Generator[None, None, None]:
def use_span(self, span: OpenTelemetrySpan) -> Generator[None]:
if not self.enabled or self.tracer is None or span.otel_span is None:
yield
return
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/dsl/document_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def __init__(self, name: str, bases: Tuple[type, ...], attrs: Dict[str, Any]):
# # ignore attributes
# field10: ClassVar[string] = "a regular class variable"
annotations = attrs.get("__annotations__", {})
fields = set([n for n in attrs if isinstance(attrs[n], Field)])
fields = {n for n in attrs if isinstance(attrs[n], Field)}
fields.update(annotations.keys())
field_defaults = {}
for name in fields:
Expand Down
2 changes: 1 addition & 1 deletion examples/fastapi-apm/dockerfiles/Dockerfile.app
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.9

EXPOSE 9292
WORKDIR /
Expand Down
2 changes: 1 addition & 1 deletion examples/fastapi-apm/dockerfiles/Dockerfile.ping
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.9
WORKDIR /
RUN python -m pip install \
--no-cache \
Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def pytest_argv():
]


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

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


@nox.session(python=["3.8", "3.13"])
@nox.session(python=["3.9", "3.13"])
def test_otel(session):
session.install(
".[dev]",
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "elasticsearch"
description = "Python client for Elasticsearch"
readme = "README.md"
license = "Apache-2.0"
requires-python = ">=3.8"
requires-python = ">=3.9"
authors = [
{ name = "Elastic Client Library Maintainers", email = "[email protected]" },
]
Expand All @@ -21,7 +21,6 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
155 changes: 83 additions & 72 deletions test_elasticsearch/test_async/test_server/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
bulk.append({"value": x})
await async_client.bulk(operations=bulk, refresh=True)

with patch.object(
async_client, "options", return_value=async_client
), patch.object(async_client, "scroll", MockScroll()):
with (
patch.object(async_client, "options", return_value=async_client),
patch.object(async_client, "scroll", MockScroll()),
):
data = [
x
async for x in helpers.async_scan(
Expand All @@ -558,9 +559,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
assert len(data) == 3
assert data[-1] == {"scroll_data": 42}

with patch.object(
async_client, "options", return_value=async_client
), patch.object(async_client, "scroll", MockScroll()):
with (
patch.object(async_client, "options", return_value=async_client),
patch.object(async_client, "scroll", MockScroll()),
):
with pytest.raises(ScanError):
data = [
x
Expand All @@ -576,9 +578,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
assert data[-1] == {"scroll_data": 42}

async def test_initial_search_error(self, async_client, scan_teardown):
with patch.object(
async_client, "options", return_value=async_client
), patch.object(async_client, "clear_scroll", new_callable=AsyncMock):
with (
patch.object(async_client, "options", return_value=async_client),
patch.object(async_client, "clear_scroll", new_callable=AsyncMock),
):
with patch.object(
async_client,
"search",
Expand Down Expand Up @@ -634,15 +637,16 @@ async def test_initial_search_error(self, async_client, scan_teardown):
assert mock_scroll.calls == []

async def test_no_scroll_id_fast_route(self, async_client, scan_teardown):
with patch.object(
async_client, "options", return_value=async_client
), patch.object(async_client, "scroll") as scroll_mock, patch.object(
async_client,
"search",
MockResponse(ObjectApiResponse(body={"no": "_scroll_id"}, meta=None)),
), patch.object(
async_client, "clear_scroll"
) as clear_mock:
with (
patch.object(async_client, "options", return_value=async_client),
patch.object(async_client, "scroll") as scroll_mock,
patch.object(
async_client,
"search",
MockResponse(ObjectApiResponse(body={"no": "_scroll_id"}, meta=None)),
),
patch.object(async_client, "clear_scroll") as clear_mock,
):
data = [
x async for x in helpers.async_scan(async_client, index="test_index")
]
Expand All @@ -661,9 +665,10 @@ async def test_logger(
bulk.append({"value": x})
await async_client.bulk(operations=bulk, refresh=True)

with patch.object(
async_client, "options", return_value=async_client
), patch.object(async_client, "scroll", MockScroll()):
with (
patch.object(async_client, "options", return_value=async_client),
patch.object(async_client, "scroll", MockScroll()),
):
_ = [
x
async for x in helpers.async_scan(
Expand All @@ -680,9 +685,10 @@ async def test_logger(
]

caplog.clear()
with patch.object(
async_client, "options", return_value=async_client
), patch.object(async_client, "scroll", MockScroll()):
with (
patch.object(async_client, "options", return_value=async_client),
patch.object(async_client, "scroll", MockScroll()),
):
with pytest.raises(ScanError):
_ = [
x
Expand All @@ -706,11 +712,12 @@ async def test_clear_scroll(self, async_client, scan_teardown):
bulk.append({"value": x})
await async_client.bulk(operations=bulk, refresh=True)

with patch.object(
async_client, "options", return_value=async_client
), patch.object(
async_client, "clear_scroll", wraps=async_client.clear_scroll
) as spy:
with (
patch.object(async_client, "options", return_value=async_client),
patch.object(
async_client, "clear_scroll", wraps=async_client.clear_scroll
) as spy,
):
_ = [
x
async for x in helpers.async_scan(
Expand Down Expand Up @@ -748,20 +755,21 @@ async def test_clear_scroll(self, async_client, scan_teardown):
async def test_scan_auth_kwargs_forwarded(
self, async_client, scan_teardown, kwargs
):
with patch.object(
async_client, "options", return_value=async_client
) as options, patch.object(
async_client,
"search",
return_value=MockResponse(
ObjectApiResponse(
body={
"_scroll_id": "scroll_id",
"_shards": {"successful": 5, "total": 5, "skipped": 0},
"hits": {"hits": [{"search_data": 1}]},
},
meta=None,
)
with (
patch.object(async_client, "options", return_value=async_client) as options,
patch.object(
async_client,
"search",
return_value=MockResponse(
ObjectApiResponse(
body={
"_scroll_id": "scroll_id",
"_shards": {"successful": 5, "total": 5, "skipped": 0},
"hits": {"hits": [{"search_data": 1}]},
},
meta=None,
)
),
),
):
with patch.object(
Expand Down Expand Up @@ -801,20 +809,21 @@ async def test_scan_auth_kwargs_forwarded(
async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
self, async_client, scan_teardown
):
with patch.object(
async_client, "options", return_value=async_client
) as options, patch.object(
async_client,
"search",
return_value=MockResponse(
ObjectApiResponse(
body={
"_scroll_id": "scroll_id",
"_shards": {"successful": 5, "total": 5, "skipped": 0},
"hits": {"hits": [{"search_data": 1}]},
},
meta=None,
)
with (
patch.object(async_client, "options", return_value=async_client) as options,
patch.object(
async_client,
"search",
return_value=MockResponse(
ObjectApiResponse(
body={
"_scroll_id": "scroll_id",
"_shards": {"successful": 5, "total": 5, "skipped": 0},
"hits": {"hits": [{"search_data": 1}]},
},
meta=None,
)
),
),
):
with patch.object(
Expand Down Expand Up @@ -878,21 +887,23 @@ async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
],
)
async def test_scan_from_keyword_is_aliased(async_client, scan_kwargs):
with patch.object(async_client, "options", return_value=async_client), patch.object(
async_client,
"search",
return_value=MockResponse(
ObjectApiResponse(
body={
"_scroll_id": "dummy_id",
"_shards": {"successful": 5, "total": 5},
"hits": {"hits": []},
},
meta=None,
)
),
) as search_mock, patch.object(
async_client, "clear_scroll", return_value=MockResponse(None)
with (
patch.object(async_client, "options", return_value=async_client),
patch.object(
async_client,
"search",
return_value=MockResponse(
ObjectApiResponse(
body={
"_scroll_id": "dummy_id",
"_shards": {"successful": 5, "total": 5},
"hits": {"hits": []},
},
meta=None,
)
),
) as search_mock,
patch.object(async_client, "clear_scroll", return_value=MockResponse(None)),
):
[
x
Expand Down
Loading
Loading