Skip to content
Open
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
2 changes: 1 addition & 1 deletion devtools/create_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fi

# check if tag to create has already been created
WORKING_DIR=`dirname $0`
VERSION=`python setup.py --version`
VERSION=`hatch project metadata version`
EXISTS=`git tag | grep $VERSION`

if [ "$VERSION" == "$EXISTS" ]
Expand Down
16 changes: 10 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling >= 1.26", "versioningit"]
requires = ["hatchling", "versioningit"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.sdist]
Expand All @@ -26,7 +26,7 @@ name = "crate"
dynamic = ["version"]
description = "CrateDB Python Client"
authors = [{ name = "Crate.io", email = "[email protected]" }]
requires-python = ">=3.10"
requires-python = ">=3.6"
readme = "README.rst"
license = "Apache-2.0"
classifiers = [
Expand All @@ -42,25 +42,29 @@ classifiers = [
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: SQL",
"Topic :: Database",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator",
"Topic :: System :: Networking",
]
dependencies = [
"importlib-metadata; python_version<'3.8'",
"orjson>=3.11.3",
"orjson",
"urllib3",
"verlib2>=0.3.1",
]

[dependency-groups]
dev = [
"certifi>=2025.10.5",
"backports.zoneinfo<1; python_version<'3.9'",
"certifi",
"coverage<8",
"mypy<1.20",
"poethepoet<1",
"pytest<10",
"pytz>=2025.2",
"pytz",
"ruff<0.15",
"setuptools>=80.9.0",
"stopit<1.2",
]

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
zc.buildout==5.1.1
zope.interface==8.1.1
zope.interface>=8
zope.testrunner>=5,<9
101 changes: 0 additions & 101 deletions setup.py

This file was deleted.

4 changes: 3 additions & 1 deletion src/crate/client/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ def duration(self):
def _convert_rows(self):
"""
Iterate rows, apply type converters, and generate converted rows.

The converter is only supported on Python >= 3.10.
"""
if not ("col_types" in self._result and self._result["col_types"]):
raise ValueError(
Expand All @@ -238,7 +240,7 @@ def _convert_rows(self):
for row in self._result["rows"]:
yield [
convert(value)
for convert, value in zip(converters, row, strict=False)
for convert, value in zip(converters, row, strict=False) # type: ignore[call-overload]
]

@property
Expand Down
25 changes: 25 additions & 0 deletions tests/client/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# software solely pursuant to the terms of the relevant commercial agreement.

import datetime
import sys
from ipaddress import IPv4Address
from unittest import mock

Expand Down Expand Up @@ -58,6 +59,9 @@ def test_cursor_fetch(mocked_connection):
]


@pytest.mark.skipif(
sys.version_info < (3, 10), reason="Test needs Python >= 3.10"
)
def test_cursor_description(mocked_connection):
cursor = mocked_connection.cursor()
response = {
Expand Down Expand Up @@ -249,6 +253,9 @@ def test_execute_with_bulk_args(mocked_connection):
mocked_connection.client.sql.assert_called_once_with(statement, None, [[1]])


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


@pytest.mark.skipif(
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
)
def test_execute_with_converter_and_invalid_data_type(mocked_connection):
converter = DefaultTypeConverter()

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


@pytest.mark.skipif(
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
)
def test_execute_array_with_converter(mocked_connection):
converter = DefaultTypeConverter()
cursor = mocked_connection.cursor(converter=converter)
Expand All @@ -345,6 +358,9 @@ def test_execute_array_with_converter(mocked_connection):
]


@pytest.mark.skipif(
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
)
def test_execute_array_with_converter_invalid(mocked_connection):
converter = DefaultTypeConverter()
cursor = mocked_connection.cursor(converter=converter)
Expand All @@ -368,6 +384,9 @@ def test_execute_array_with_converter_invalid(mocked_connection):
)


@pytest.mark.skipif(
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
)
def test_execute_nested_array_with_converter(mocked_connection):
converter = DefaultTypeConverter()
cursor = mocked_connection.cursor(converter=converter)
Expand Down Expand Up @@ -405,6 +424,9 @@ def test_execute_nested_array_with_converter(mocked_connection):
]


@pytest.mark.skipif(
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
)
def test_executemany_with_converter(mocked_connection):
converter = DefaultTypeConverter()
cursor = mocked_connection.cursor(converter=converter)
Expand All @@ -426,6 +448,9 @@ def test_executemany_with_converter(mocked_connection):
assert result == []


@pytest.mark.skipif(
sys.version_info < (3, 10), reason="Converter needs Python >= 3.10"
)
def test_execute_with_timezone(mocked_connection):
# Create a `Cursor` object with `time_zone`.
tz_mst = datetime.timezone(datetime.timedelta(hours=7), name="MST")
Expand Down
20 changes: 12 additions & 8 deletions tests/client/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import doctest
import sys
import unittest

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

s = doctest.DocFileSuite(
"docs/by-example/connection.rst",
"docs/by-example/cursor.rst",
module_relative=False,
optionflags=flags,
encoding="utf-8",
)
suite.addTest(s)
if sys.version_info >= (3, 10):
# This suite includes converter tests,
# which are only available with Python 3.10 and newer.
s = doctest.DocFileSuite(
"docs/by-example/connection.rst",
"docs/by-example/cursor.rst",
module_relative=False,
optionflags=flags,
encoding="utf-8",
)
suite.addTest(s)

s = doctest.DocFileSuite(
"docs/by-example/https.rst",
Expand Down
Loading