Skip to content

Support Python 3.9 to 3.12 #61

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 1 commit into from
Jun 21, 2024
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
4 changes: 2 additions & 2 deletions .buildkite/generatesteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def benchmark_to_steps(python, connection_class):
"env": {
"PYTHON_VERSION": f"{python}",
"PYTHON_CONNECTION_CLASS": f"{connection_class}",
# TEMPORARY for 3.11
# For development versions
# https://github.com/aio-libs/aiohttp/issues/6600
"AIOHTTP_NO_EXTENSIONS": 1,
# https://github.com/aio-libs/frozenlist/issues/285
Expand Down Expand Up @@ -53,7 +53,7 @@ def benchmark_to_steps(python, connection_class):

if __name__ == "__main__":
steps = []
for python in ["3.7", "3.8", "3.9", "3.10", "3.11"]:
for python in ["3.9", "3.10", "3.11", "3.12"]:
for connection_class in ["urllib3", "requests"]:
steps.extend(benchmark_to_steps(python, connection_class))
print(yaml.dump({"steps": steps}, Dumper=yaml.Dumper, sort_keys=False))
2 changes: 1 addition & 1 deletion .buildkite/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail

# Default environment variables
export FORCE_COLOR=1
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}"
export PYTHON_VERSION="${PYTHON_VERSION:=3.12}"
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}"
export EC_PROJECT_NAME="$EC_PROJECT_PREFIX-$BUILDKITE_JOB_ID"
buildkite-agent meta-data set $EC_PROJECT_PREFIX $EC_PROJECT_NAME
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/teardown-tests
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

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

Expand Down
2 changes: 1 addition & 1 deletion .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_VERSION=3.9
ARG PYTHON_VERSION=3.12
FROM python:${PYTHON_VERSION}

WORKDIR /code/elasticsearch-serverless-python
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
experimental: [false]
nox-session: [""]
runs-on: ["ubuntu-latest"]
Expand All @@ -74,6 +74,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: |
python -m pip install nox
Expand All @@ -83,7 +84,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
NOX_SESSION: ${{ matrix.nox-session }}
# TEMPORARY for 3.11
# For development versions
# https://github.com/aio-libs/aiohttp/issues/6600
AIOHTTP_NO_EXTENSIONS: 1
# https://github.com/aio-libs/frozenlist/issues/285
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ es = Elasticsearch(
[discrete]
==== TLS versions

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

[source,python]
------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ operations with it.
[discrete]
=== Requirements

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

[discrete]
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
INSTALL_ENV = {"AIOHTTP_NO_EXTENSIONS": "1"}


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

Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.2.0.20231031"
description = "Python client for Elasticsearch Serverless"
readme = "README.rst"
license = "Apache-2.0"
requires-python = ">=3.7, <4"
requires-python = ">=3.9"
authors = [
{ name = "Elastic Client Library Maintainers", email = "client-libs@elastic.co" },
]
Expand All @@ -22,13 +22,12 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
keywords = [
"elasticsearch",
Expand Down
155 changes: 83 additions & 72 deletions test_elasticsearch_serverless/test_async/test_server/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,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 @@ -514,9 +515,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 @@ -532,9 +534,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 @@ -590,15 +593,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 @@ -615,9 +619,10 @@ async def test_logger(self, logger_mock, 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()),
):
_ = [
x
async for x in helpers.async_scan(
Expand All @@ -630,9 +635,10 @@ async def test_logger(self, logger_mock, async_client, scan_teardown):
]
logger_mock.warning.assert_called()

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()),
):
try:
_ = [
x
Expand Down Expand Up @@ -660,11 +666,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 @@ -702,20 +709,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 @@ -755,20 +763,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 @@ -832,21 +841,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