Skip to content

Commit e0ecf9f

Browse files
authored
Merge pull request #11 from Pavkazzz/python3.12
Add python3.12
2 parents 86af17a + db46fd0 commit e0ecf9f

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed

.github/workflows/lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Setup python3.11
16+
- name: Setup python3.12
1717
uses: actions/setup-python@v4
1818
with:
19-
python-version: '3.11'
19+
python-version: '3.12'
2020
- run: python -m pip install poetry==1.6
2121
- run: poetry install
2222
- run: poetry run ruff simdjson_schemaful tests

.github/workflows/publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
contents: read
1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Setup python3.11
16+
- name: Setup python3.12
1717
uses: actions/setup-python@v4
1818
with:
19-
python-version: '3.11'
19+
python-version: '3.12'
2020

2121
- name: Install poetry
2222
run: python -m pip install poetry

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- '3.9'
2424
- '3.10'
2525
- '3.11'
26+
- '3.12'
2627
steps:
2728
- uses: actions/checkout@v4
2829
- name: Setup python${{ matrix.python }}

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PROJECT_NAME := simdjson_schemaful
2-
PROJECT_PATH := $(PROJECT_PATH)
2+
PROJECT_PATH := $(PROJECT_NAME)
33
PYTHON_IMAGE := docker.io/snakepacker/python:all
44

55
all:

pyproject.toml

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ classifiers = [
1717
"Programming Language :: Python :: 3.9",
1818
"Programming Language :: Python :: 3.10",
1919
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
2021
"Programming Language :: Python :: Implementation :: CPython",
2122
"Programming Language :: Python",
2223
"Topic :: Internet",
@@ -46,12 +47,13 @@ name = "pypi"
4647
priority = "primary"
4748

4849
[tool.poetry.dependencies]
49-
python = ">=3.8,<3.12"
50+
python = ">=3.8,<3.13"
5051
pysimdjson = [
51-
{version=">=2,<6", python=">=3.8,<3.9"},
52-
{version=">=3,<6", python=">=3.9,<3.11"},
52+
{version=">=2,<7", python=">=3.8,<3.9"},
53+
{version=">=3,<7", python=">=3.9,<3.11"},
5354
# version 4 does not build for 3.11 for some reason
54-
{version=">=3,!=4.*,<6", python=">=3.11,<3.12"},
55+
{version=">=3,!=4.*,<7", python=">=3.11,<3.12"},
56+
{version=">=6,<7", python=">=3.12,<3.13"},
5557
]
5658
pydantic = { version = ">=1,<3", optional = true }
5759

simdjson_schemaful/pydantic/v2.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from typing import TYPE_CHECKING, Any, Dict, Optional, Type, TypeVar, Union
2+
from typing import TYPE_CHECKING, Any, Dict, Generic, Optional, Type, TypeVar, Union
33

44
import pydantic
55
from pydantic import ValidationError
@@ -38,10 +38,16 @@ def model_validate_simdjson(
3838
return cls.model_validate(obj)
3939

4040

41-
class TypeAdapter(pydantic.TypeAdapter[T]):
41+
class TypeAdapter(Generic[T]):
42+
__slots__ = ("_ta", "_simdjson_schema")
43+
4244
def __init__(self, *args: Any, **kwargs: Any) -> None:
43-
super().__init__(*args, **kwargs)
44-
self._simdjson_schema = self.json_schema()
45+
self._ta = pydantic.TypeAdapter[T](*args, **kwargs)
46+
self._simdjson_schema = self._ta.json_schema()
47+
48+
@property
49+
def pydantic_type_adapter(self) -> pydantic.TypeAdapter[T]:
50+
return self._ta
4551

4652
def _build_error(self, exc: Exception, data: Union[str, bytes]) -> ValidationError:
4753
if isinstance(exc, UnicodeDecodeError):
@@ -58,7 +64,10 @@ def _build_error(self, exc: Exception, data: Union[str, bytes]) -> ValidationErr
5864
"loc": ("__root__",),
5965
"input": data,
6066
}
61-
return ValidationError.from_exception_data(self.core_schema["type"], [details])
67+
return ValidationError.from_exception_data(
68+
self._ta.core_schema["type"],
69+
[details],
70+
)
6271

6372
def validate_simdjson(
6473
self,
@@ -72,4 +81,4 @@ def validate_simdjson(
7281
obj = loads(data, schema=self._simdjson_schema, parser=parser)
7382
except (ValueError, TypeError, UnicodeDecodeError) as e:
7483
raise self._build_error(e, data)
75-
return self.validate_python(obj, strict=strict, context=context)
84+
return self._ta.validate_python(obj, strict=strict, context=context)

tox.ini

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
[tox]
22
isolated_build = True
3-
envlist = py{38}-pydantic{1,2}-pysimdjson{2,3,4,5},\
4-
py{39,310}-pydantic{1,2}-pysimdjson{3,4,5},\
5-
py{311}-pydantic{1,2}-pysimdjson{3,5}
3+
envlist = py{38}-pydantic{1,2}-pysimdjson{2,3,4,5,6},\
4+
py{39,310}-pydantic{1,2}-pysimdjson{3,4,5,6},\
5+
py{311}-pydantic{1,2}-pysimdjson{3,5,6},\
6+
py{312}-pydantic{1,2}-pysimdjson{6}
67
toxworkdir = {env:TOXDIR:.tox}
78

89
labels =
9-
py38 = py38-pydantic{1,2}-pysimdjson{2,3,4,5}
10-
py39 = py39-pydantic{1,2}-pysimdjson{3,4,5}
11-
py310 = py310-pydantic{1,2}-pysimdjson{3,4,5}
12-
py311 = py311-pydantic{1,2}-pysimdjson{3,5}
10+
py38 = py38-pydantic{1,2}-pysimdjson{2,3,4,5,6}
11+
py39 = py39-pydantic{1,2}-pysimdjson{3,4,5,6}
12+
py310 = py310-pydantic{1,2}-pysimdjson{3,4,5,6}
13+
py311 = py311-pydantic{1,2}-pysimdjson{3,5,6}
14+
py312 = py312-pydantic{1,2}-pysimdjson{6}
1315

1416
[testenv]
1517
passenv=
@@ -26,6 +28,7 @@ deps =
2628
pysimdjson3: pysimdjson~=3.0
2729
pysimdjson4: pysimdjson~=4.0
2830
pysimdjson5: pysimdjson~=5.0
31+
pysimdjson6: pysimdjson~=6.0
2932

3033
commands = pytest tests
3134

0 commit comments

Comments
 (0)