Skip to content

Commit 5eca793

Browse files
committed
Support Python 3.9 to 3.13
1 parent b09712c commit 5eca793

File tree

11 files changed

+235
-199
lines changed

11 files changed

+235
-199
lines changed

.buildkite/generatesteps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def benchmark_to_steps(python, connection_class):
1414
"env": {
1515
"PYTHON_VERSION": f"{python}",
1616
"PYTHON_CONNECTION_CLASS": f"{connection_class}",
17-
# TEMPORARY for 3.11
17+
# For development versions
1818
# https://github.com/aio-libs/aiohttp/issues/6600
1919
"AIOHTTP_NO_EXTENSIONS": 1,
2020
# https://github.com/aio-libs/frozenlist/issues/285
@@ -53,7 +53,7 @@ def benchmark_to_steps(python, connection_class):
5353

5454
if __name__ == "__main__":
5555
steps = []
56-
for python in ["3.7", "3.8", "3.9", "3.10", "3.11"]:
56+
for python in ["3.9", "3.10", "3.11", "3.12"]:
5757
for connection_class in ["urllib3", "requests"]:
5858
steps.extend(benchmark_to_steps(python, connection_class))
5959
print(yaml.dump({"steps": steps}, Dumper=yaml.Dumper, sort_keys=False))

.buildkite/run-tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -euo pipefail
33

44
# Default environment variables
55
export FORCE_COLOR=1
6-
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}"
6+
export PYTHON_VERSION="${PYTHON_VERSION:=3.12}"
77
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}"
88
export EC_PROJECT_NAME="$EC_PROJECT_PREFIX-$BUILDKITE_JOB_ID"
99
buildkite-agent meta-data set $EC_PROJECT_PREFIX $EC_PROJECT_NAME

.buildkite/teardown-tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euo pipefail
33

44
# Default environment variables
5-
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}"
5+
export PYTHON_VERSION="${PYTHON_VERSION:=3.12}"
66
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}"
77
export EC_PROJECT_NAME=$(buildkite-agent meta-data get $EC_PROJECT_PREFIX)
88

.github/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PYTHON_VERSION=3.9
1+
ARG PYTHON_VERSION=3.12
22
FROM python:${PYTHON_VERSION}
33

44
WORKDIR /code/elasticsearch-serverless-python

.github/workflows/tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
strategy:
6060
fail-fast: false
6161
matrix:
62-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
62+
python-version: ["3.9", "3.10", "3.11", "3.12"]
6363
experimental: [false]
6464
nox-session: [""]
6565
runs-on: ["ubuntu-latest"]
@@ -74,6 +74,7 @@ jobs:
7474
uses: actions/setup-python@v4
7575
with:
7676
python-version: ${{ matrix.python-version }}
77+
allow-prereleases: true
7778
- name: Install dependencies
7879
run: |
7980
python -m pip install nox
@@ -83,7 +84,7 @@ jobs:
8384
env:
8485
PYTHON_VERSION: ${{ matrix.python-version }}
8586
NOX_SESSION: ${{ matrix.nox-session }}
86-
# TEMPORARY for 3.11
87+
# For development versions
8788
# https://github.com/aio-libs/aiohttp/issues/6600
8889
AIOHTTP_NO_EXTENSIONS: 1
8990
# https://github.com/aio-libs/frozenlist/issues/285

docs/guide/configuration.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ es = Elasticsearch(
5252
[discrete]
5353
==== TLS versions
5454

55-
Configuring the minimum TLS version to connect to is done via the `ssl_version` parameter. By default this is set to a minimum value of TLSv1.2. In Python 3.7+ you can use the new `ssl.TLSVersion` enumeration to specify versions.
55+
Configuring the minimum TLS version to connect to is done via the `ssl_version` parameter. By default this is set to a minimum value of TLSv1.2. You can use the new `ssl.TLSVersion` enumeration to specify versions.
5656

5757
[source,python]
5858
------------------------------------

docs/guide/getting-started.asciidoc

Lines changed: 1 addition & 1 deletion
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.9 or newer
1212
* https://pip.pypa.io/en/stable/[`pip`], installed by default alongside Python
1313

1414
[discrete]

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
INSTALL_ENV = {"AIOHTTP_NO_EXTENSIONS": "1"}
3232

3333

34-
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
34+
@nox.session(python=["3.9", "3.10", "3.11", "3.12"])
3535
def test(session):
3636
session.install(".[dev]", env=INSTALL_ENV)
3737

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ version = "0.2.0.20231031"
88
description = "Python client for Elasticsearch Serverless"
99
readme = "README.rst"
1010
license = "Apache-2.0"
11-
requires-python = ">=3.7, <4"
11+
requires-python = ">=3.9"
1212
authors = [
1313
{ name = "Elastic Client Library Maintainers", email = "client-libs@elastic.co" },
1414
]
@@ -22,13 +22,12 @@ classifiers = [
2222
"Operating System :: OS Independent",
2323
"Programming Language :: Python",
2424
"Programming Language :: Python :: 3",
25-
"Programming Language :: Python :: 3.7",
26-
"Programming Language :: Python :: 3.8",
2725
"Programming Language :: Python :: 3.9",
28-
"Programming Language :: Python :: Implementation :: CPython",
29-
"Programming Language :: Python :: Implementation :: PyPy",
3026
"Programming Language :: Python :: 3.10",
3127
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: Implementation :: CPython",
30+
"Programming Language :: Python :: Implementation :: PyPy",
3231
]
3332
keywords = [
3433
"elasticsearch",

test_elasticsearch_serverless/test_async/test_server/test_helpers.py

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

501-
with patch.object(
502-
async_client, "options", return_value=async_client
503-
), patch.object(async_client, "scroll", MockScroll()):
501+
with (
502+
patch.object(async_client, "options", return_value=async_client),
503+
patch.object(async_client, "scroll", MockScroll()),
504+
):
504505
data = [
505506
x
506507
async for x in helpers.async_scan(
@@ -514,9 +515,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
514515
assert len(data) == 3
515516
assert data[-1] == {"scroll_data": 42}
516517

517-
with patch.object(
518-
async_client, "options", return_value=async_client
519-
), patch.object(async_client, "scroll", MockScroll()):
518+
with (
519+
patch.object(async_client, "options", return_value=async_client),
520+
patch.object(async_client, "scroll", MockScroll()),
521+
):
520522
with pytest.raises(ScanError):
521523
data = [
522524
x
@@ -532,9 +534,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
532534
assert data[-1] == {"scroll_data": 42}
533535

534536
async def test_initial_search_error(self, async_client, scan_teardown):
535-
with patch.object(
536-
async_client, "options", return_value=async_client
537-
), patch.object(async_client, "clear_scroll", new_callable=AsyncMock):
537+
with (
538+
patch.object(async_client, "options", return_value=async_client),
539+
patch.object(async_client, "clear_scroll", new_callable=AsyncMock),
540+
):
538541
with patch.object(
539542
async_client,
540543
"search",
@@ -590,15 +593,16 @@ async def test_initial_search_error(self, async_client, scan_teardown):
590593
assert mock_scroll.calls == []
591594

592595
async def test_no_scroll_id_fast_route(self, async_client, scan_teardown):
593-
with patch.object(
594-
async_client, "options", return_value=async_client
595-
), patch.object(async_client, "scroll") as scroll_mock, patch.object(
596-
async_client,
597-
"search",
598-
MockResponse(ObjectApiResponse(body={"no": "_scroll_id"}, meta=None)),
599-
), patch.object(
600-
async_client, "clear_scroll"
601-
) as clear_mock:
596+
with (
597+
patch.object(async_client, "options", return_value=async_client),
598+
patch.object(async_client, "scroll") as scroll_mock,
599+
patch.object(
600+
async_client,
601+
"search",
602+
MockResponse(ObjectApiResponse(body={"no": "_scroll_id"}, meta=None)),
603+
),
604+
patch.object(async_client, "clear_scroll") as clear_mock,
605+
):
602606
data = [
603607
x async for x in helpers.async_scan(async_client, index="test_index")
604608
]
@@ -615,9 +619,10 @@ async def test_logger(self, logger_mock, async_client, scan_teardown):
615619
bulk.append({"value": x})
616620
await async_client.bulk(operations=bulk, refresh=True)
617621

618-
with patch.object(
619-
async_client, "options", return_value=async_client
620-
), patch.object(async_client, "scroll", MockScroll()):
622+
with (
623+
patch.object(async_client, "options", return_value=async_client),
624+
patch.object(async_client, "scroll", MockScroll()),
625+
):
621626
_ = [
622627
x
623628
async for x in helpers.async_scan(
@@ -630,9 +635,10 @@ async def test_logger(self, logger_mock, async_client, scan_teardown):
630635
]
631636
logger_mock.warning.assert_called()
632637

633-
with patch.object(
634-
async_client, "options", return_value=async_client
635-
), patch.object(async_client, "scroll", MockScroll()):
638+
with (
639+
patch.object(async_client, "options", return_value=async_client),
640+
patch.object(async_client, "scroll", MockScroll()),
641+
):
636642
try:
637643
_ = [
638644
x
@@ -660,11 +666,12 @@ async def test_clear_scroll(self, async_client, scan_teardown):
660666
bulk.append({"value": x})
661667
await async_client.bulk(operations=bulk, refresh=True)
662668

663-
with patch.object(
664-
async_client, "options", return_value=async_client
665-
), patch.object(
666-
async_client, "clear_scroll", wraps=async_client.clear_scroll
667-
) as spy:
669+
with (
670+
patch.object(async_client, "options", return_value=async_client),
671+
patch.object(
672+
async_client, "clear_scroll", wraps=async_client.clear_scroll
673+
) as spy,
674+
):
668675
_ = [
669676
x
670677
async for x in helpers.async_scan(
@@ -702,20 +709,21 @@ async def test_clear_scroll(self, async_client, scan_teardown):
702709
async def test_scan_auth_kwargs_forwarded(
703710
self, async_client, scan_teardown, kwargs
704711
):
705-
with patch.object(
706-
async_client, "options", return_value=async_client
707-
) as options, patch.object(
708-
async_client,
709-
"search",
710-
return_value=MockResponse(
711-
ObjectApiResponse(
712-
body={
713-
"_scroll_id": "scroll_id",
714-
"_shards": {"successful": 5, "total": 5, "skipped": 0},
715-
"hits": {"hits": [{"search_data": 1}]},
716-
},
717-
meta=None,
718-
)
712+
with (
713+
patch.object(async_client, "options", return_value=async_client) as options,
714+
patch.object(
715+
async_client,
716+
"search",
717+
return_value=MockResponse(
718+
ObjectApiResponse(
719+
body={
720+
"_scroll_id": "scroll_id",
721+
"_shards": {"successful": 5, "total": 5, "skipped": 0},
722+
"hits": {"hits": [{"search_data": 1}]},
723+
},
724+
meta=None,
725+
)
726+
),
719727
),
720728
):
721729
with patch.object(
@@ -755,20 +763,21 @@ async def test_scan_auth_kwargs_forwarded(
755763
async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
756764
self, async_client, scan_teardown
757765
):
758-
with patch.object(
759-
async_client, "options", return_value=async_client
760-
) as options, 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-
)
766+
with (
767+
patch.object(async_client, "options", return_value=async_client) as options,
768+
patch.object(
769+
async_client,
770+
"search",
771+
return_value=MockResponse(
772+
ObjectApiResponse(
773+
body={
774+
"_scroll_id": "scroll_id",
775+
"_shards": {"successful": 5, "total": 5, "skipped": 0},
776+
"hits": {"hits": [{"search_data": 1}]},
777+
},
778+
meta=None,
779+
)
780+
),
772781
),
773782
):
774783
with patch.object(
@@ -832,21 +841,23 @@ async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
832841
],
833842
)
834843
async def test_scan_from_keyword_is_aliased(async_client, scan_kwargs):
835-
with patch.object(async_client, "options", return_value=async_client), patch.object(
836-
async_client,
837-
"search",
838-
return_value=MockResponse(
839-
ObjectApiResponse(
840-
body={
841-
"_scroll_id": "dummy_id",
842-
"_shards": {"successful": 5, "total": 5},
843-
"hits": {"hits": []},
844-
},
845-
meta=None,
846-
)
847-
),
848-
) as search_mock, patch.object(
849-
async_client, "clear_scroll", return_value=MockResponse(None)
844+
with (
845+
patch.object(async_client, "options", return_value=async_client),
846+
patch.object(
847+
async_client,
848+
"search",
849+
return_value=MockResponse(
850+
ObjectApiResponse(
851+
body={
852+
"_scroll_id": "dummy_id",
853+
"_shards": {"successful": 5, "total": 5},
854+
"hits": {"hits": []},
855+
},
856+
meta=None,
857+
)
858+
),
859+
) as search_mock,
860+
patch.object(async_client, "clear_scroll", return_value=MockResponse(None)),
850861
):
851862
[
852863
x

0 commit comments

Comments
 (0)