Skip to content

Commit fd534ff

Browse files
committed
Dependencies: Improve Python compatibility
1 parent 5f148bc commit fd534ff

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling >= 1.26", "versioningit"]
2+
requires = ["hatchling", "versioningit"]
33
build-backend = "hatchling.build"
44

55
[tool.hatch.build.targets.sdist]
@@ -26,7 +26,7 @@ name = "crate"
2626
dynamic = ["version"]
2727
description = "CrateDB Python Client"
2828
authors = [{ name = "Crate.io", email = "[email protected]" }]
29-
requires-python = ">=3.10"
29+
requires-python = ">=3.6"
3030
readme = "README.rst"
3131
license = "Apache-2.0"
3232
classifiers = [
@@ -50,21 +50,21 @@ classifiers = [
5050
]
5151
dependencies = [
5252
"importlib-metadata; python_version<'3.8'",
53-
"orjson>=3.11.3",
53+
"orjson",
5454
"urllib3",
5555
"verlib2>=0.3.1",
5656
]
5757

5858
[dependency-groups]
5959
dev = [
60-
"certifi>=2025.10.5",
60+
"backports.zoneinfo<1; python_version<'3.9'",
61+
"certifi",
6162
"coverage<8",
6263
"mypy<1.20",
6364
"poethepoet<1",
6465
"pytest<10",
65-
"pytz>=2025.2",
66+
"pytz",
6667
"ruff<0.15",
67-
"setuptools>=80.9.0",
6868
"stopit<1.2",
6969
]
7070

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
zc.buildout==5.1.1
2-
zope.interface==8.1.1
2+
zope.interface>=8
33
zope.testrunner>=5,<9

src/crate/client/cursor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ def duration(self):
221221
def _convert_rows(self):
222222
"""
223223
Iterate rows, apply type converters, and generate converted rows.
224+
225+
The converter is only supported on Python >= 3.10.
224226
"""
225227
if not ("col_types" in self._result and self._result["col_types"]):
226228
raise ValueError(
@@ -238,7 +240,7 @@ def _convert_rows(self):
238240
for row in self._result["rows"]:
239241
yield [
240242
convert(value)
241-
for convert, value in zip(converters, row, strict=False)
243+
for convert, value in zip(converters, row, strict=False) # type: ignore[call-overload]
242244
]
243245

244246
@property

tests/client/test_cursor.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121

2222
import datetime
23+
import sys
2324
from ipaddress import IPv4Address
2425
from unittest import mock
2526

@@ -58,6 +59,9 @@ def test_cursor_fetch(mocked_connection):
5859
]
5960

6061

62+
@pytest.mark.skipif(
63+
sys.version_info < (3, 10), reason="Test needs Python >= 3.10"
64+
)
6165
def test_cursor_description(mocked_connection):
6266
cursor = mocked_connection.cursor()
6367
response = {
@@ -249,6 +253,9 @@ def test_execute_with_bulk_args(mocked_connection):
249253
mocked_connection.client.sql.assert_called_once_with(statement, None, [[1]])
250254

251255

256+
@pytest.mark.skipif(
257+
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
258+
)
252259
def test_execute_custom_converter(mocked_connection):
253260
"""
254261
Verify that a custom converter is correctly applied when passed to a cursor.
@@ -299,6 +306,9 @@ def test_execute_custom_converter(mocked_connection):
299306
]
300307

301308

309+
@pytest.mark.skipif(
310+
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
311+
)
302312
def test_execute_with_converter_and_invalid_data_type(mocked_connection):
303313
converter = DefaultTypeConverter()
304314

@@ -323,6 +333,9 @@ def test_execute_with_converter_and_invalid_data_type(mocked_connection):
323333
assert e.exception.args == "999 is not a valid DataType"
324334

325335

336+
@pytest.mark.skipif(
337+
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
338+
)
326339
def test_execute_array_with_converter(mocked_connection):
327340
converter = DefaultTypeConverter()
328341
cursor = mocked_connection.cursor(converter=converter)
@@ -345,6 +358,9 @@ def test_execute_array_with_converter(mocked_connection):
345358
]
346359

347360

361+
@pytest.mark.skipif(
362+
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
363+
)
348364
def test_execute_array_with_converter_invalid(mocked_connection):
349365
converter = DefaultTypeConverter()
350366
cursor = mocked_connection.cursor(converter=converter)
@@ -368,6 +384,9 @@ def test_execute_array_with_converter_invalid(mocked_connection):
368384
)
369385

370386

387+
@pytest.mark.skipif(
388+
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
389+
)
371390
def test_execute_nested_array_with_converter(mocked_connection):
372391
converter = DefaultTypeConverter()
373392
cursor = mocked_connection.cursor(converter=converter)
@@ -405,6 +424,9 @@ def test_execute_nested_array_with_converter(mocked_connection):
405424
]
406425

407426

427+
@pytest.mark.skipif(
428+
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
429+
)
408430
def test_executemany_with_converter(mocked_connection):
409431
converter = DefaultTypeConverter()
410432
cursor = mocked_connection.cursor(converter=converter)
@@ -426,6 +448,9 @@ def test_executemany_with_converter(mocked_connection):
426448
assert result == []
427449

428450

451+
@pytest.mark.skipif(
452+
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
453+
)
429454
def test_execute_with_timezone(mocked_connection):
430455
# Create a `Cursor` object with `time_zone`.
431456
tz_mst = datetime.timezone(datetime.timedelta(hours=7), name="MST")

tests/client/tests.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import doctest
2+
import sys
23
import unittest
34

45
from .layer import (
@@ -18,14 +19,17 @@ def test_suite():
1819
suite.addTest(doctest.DocTestSuite("crate.client.connection"))
1920
suite.addTest(doctest.DocTestSuite("crate.client.http"))
2021

21-
s = doctest.DocFileSuite(
22-
"docs/by-example/connection.rst",
23-
"docs/by-example/cursor.rst",
24-
module_relative=False,
25-
optionflags=flags,
26-
encoding="utf-8",
27-
)
28-
suite.addTest(s)
22+
if sys.version_info >= (3, 10):
23+
# This suite includes converter tests,
24+
# which are only available with Python 3.10 and newer.
25+
s = doctest.DocFileSuite(
26+
"docs/by-example/connection.rst",
27+
"docs/by-example/cursor.rst",
28+
module_relative=False,
29+
optionflags=flags,
30+
encoding="utf-8",
31+
)
32+
suite.addTest(s)
2933

3034
s = doctest.DocFileSuite(
3135
"docs/by-example/https.rst",

0 commit comments

Comments
 (0)