structtype 0.8.1__tar.gz → 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {structtype-0.8.1 → structtype-0.9.0}/AGENTS.md +4 -2
- {structtype-0.8.1/src/structtype.egg-info → structtype-0.9.0}/PKG-INFO +1 -1
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/__init__.py +12 -12
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/__init__.pyi +8 -8
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_config.py +1 -1
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_core.c +462 -372
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_inspect.py +6 -6
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_version.py +2 -2
- {structtype-0.8.1 → structtype-0.9.0/src/structtype.egg-info}/PKG-INFO +1 -1
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_adapter.py +5 -5
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_annotations.py +237 -237
- structtype-0.9.0/tests/test_check.py +389 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_constraints.py +91 -91
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_inspect.py +15 -15
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_json.py +3 -3
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_schema.py +17 -17
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_struct_meta.py +2 -2
- {structtype-0.8.1 → structtype-0.9.0}/tests/typecheck/basic.py +1 -1
- {structtype-0.8.1 → structtype-0.9.0}/tests/typecheck/fields.py +7 -7
- structtype-0.8.1/tests/test_check.py +0 -270
- {structtype-0.8.1 → structtype-0.9.0}/.opencode/opencode.json +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/.opencode/plugins/graphify.js +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/LICENSE +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/MANIFEST.in +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/Makefile +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/README.md +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/pyproject.toml +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/setup.cfg +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/setup.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_adapter.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_json_schema.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_utils.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/atof.h +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/atof_consts.h +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/common.h +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/itoa.h +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/py.typed +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype/ryu.h +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype.egg-info/SOURCES.txt +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype.egg-info/dependency_links.txt +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/src/structtype.egg-info/top_level.txt +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/__init__.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/conftest.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_JSONTestSuite.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_attrs.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_cpylint.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_free_threading.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_memory.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_msgspec.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_pydantic.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_raw.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_struct.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_typecheck.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/test_utils.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/typecheck/api.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/typecheck/types.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/tests/utils.py +0 -0
- {structtype-0.8.1 → structtype-0.9.0}/uv.lock +0 -0
|
@@ -40,7 +40,9 @@ All commands go through `make`.
|
|
|
40
40
|
## Key API
|
|
41
41
|
|
|
42
42
|
- `structtype.Struct` — base class with config options (frozen, tag, rename, etc.)
|
|
43
|
-
- `structtype.Field` — field
|
|
43
|
+
- `structtype.Field` — field metadata (alias, title, description, examples, deprecated, json_schema_extra)
|
|
44
|
+
- `structtype.Constraint` — base constraint (callable `fn`); subclasses: `NumericConstraint`, `StrConstraint`, `BytesConstraint`, `CollectionConstraint`, `TimezoneConstraint`
|
|
45
|
+
- `structtype.Serializer` — custom-type load/dump codecs
|
|
44
46
|
- `structtype.Raw` — lazy JSON passthrough
|
|
45
47
|
- `structtype.fields(type_or_instance)` — get FieldInfo tuple for a struct type/instance
|
|
46
48
|
- `structtype._inspect.type_info()` / `multi_type_info()` — type introspection
|
|
@@ -49,7 +51,7 @@ All commands go through `make`.
|
|
|
49
51
|
|
|
50
52
|
- `obj.struct_dump_json(*, decimal_format=None, uuid_format=None, sort_keys=False)` — serialize to JSON bytes
|
|
51
53
|
- `obj.struct_dump(*, sort_keys=False, str_keys=False, builtin_types=None)` — convert to built-in Python types (uses `alias` for keys)
|
|
52
|
-
- `obj.
|
|
54
|
+
- `obj.struct_check_types()` — validate field values against types + constraints (pure type-check, no conversion)
|
|
53
55
|
- `cls.struct_validate_json(buf, *, strict=True)` — deserialize from JSON
|
|
54
56
|
- `cls.struct_validate(obj, *, strict=True, from_attributes=False)` — convert built-in types to struct
|
|
55
57
|
|
|
@@ -4,22 +4,22 @@ from ._core import ( # type: ignore
|
|
|
4
4
|
ALL_BUILTIN_TYPES,
|
|
5
5
|
NODEFAULT,
|
|
6
6
|
UNSET,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
BytesConstraint,
|
|
8
|
+
CollectionConstraint,
|
|
9
|
+
Constraint,
|
|
9
10
|
DecodeError,
|
|
10
11
|
EncodeError,
|
|
11
12
|
Factory,
|
|
12
13
|
Field,
|
|
13
|
-
|
|
14
|
+
NumericConstraint,
|
|
14
15
|
Raw,
|
|
15
16
|
Serializer,
|
|
17
|
+
StrConstraint,
|
|
16
18
|
Struct,
|
|
17
19
|
StructMeta,
|
|
18
|
-
|
|
19
|
-
TimezoneValidator,
|
|
20
|
+
TimezoneConstraint,
|
|
20
21
|
UnsetType,
|
|
21
22
|
ValidationError,
|
|
22
|
-
Validator,
|
|
23
23
|
)
|
|
24
24
|
from ._inspect import FieldInfo, fields
|
|
25
25
|
from ._json_schema import json_schema, json_schema_components, json_schema_dump
|
|
@@ -29,25 +29,25 @@ __all__ = [
|
|
|
29
29
|
"ALL_BUILTIN_TYPES",
|
|
30
30
|
"NODEFAULT",
|
|
31
31
|
"UNSET",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"BytesConstraint",
|
|
33
|
+
"CollectionConstraint",
|
|
34
|
+
"Constraint",
|
|
34
35
|
"DecodeError",
|
|
35
36
|
"EncodeError",
|
|
36
37
|
"Factory",
|
|
37
38
|
"Field",
|
|
38
39
|
"FieldInfo",
|
|
39
|
-
"
|
|
40
|
+
"NumericConstraint",
|
|
40
41
|
"Raw",
|
|
41
42
|
"Serializer",
|
|
42
|
-
"
|
|
43
|
+
"StrConstraint",
|
|
43
44
|
"Struct",
|
|
44
45
|
"StructAdapter",
|
|
45
46
|
"StructConfig",
|
|
46
47
|
"StructMeta",
|
|
47
|
-
"
|
|
48
|
+
"TimezoneConstraint",
|
|
48
49
|
"UnsetType",
|
|
49
50
|
"ValidationError",
|
|
50
|
-
"Validator",
|
|
51
51
|
"__version__",
|
|
52
52
|
"fields",
|
|
53
53
|
"json_schema",
|
|
@@ -37,7 +37,7 @@ class StructConfig(TypedDict, total=False):
|
|
|
37
37
|
repr_omit_defaults: bool
|
|
38
38
|
omit_defaults: bool
|
|
39
39
|
forbid_unknown_fields: bool
|
|
40
|
-
|
|
40
|
+
check_types_on_init: bool
|
|
41
41
|
weakref: bool
|
|
42
42
|
dict: bool
|
|
43
43
|
cache_hash: bool
|
|
@@ -94,7 +94,7 @@ class Struct(metaclass=StructMeta):
|
|
|
94
94
|
str_keys: bool = False,
|
|
95
95
|
builtin_types: Iterable[type] | None = None,
|
|
96
96
|
) -> dict[str, Any] | list[Any]: ...
|
|
97
|
-
def
|
|
97
|
+
def struct_check_types(self) -> None: ...
|
|
98
98
|
@classmethod
|
|
99
99
|
def struct_validate_json(
|
|
100
100
|
cls,
|
|
@@ -160,12 +160,12 @@ class Serializer:
|
|
|
160
160
|
load: Final[Callable[[Any], Any] | None]
|
|
161
161
|
dump: Final[Callable[[Any], Any] | None]
|
|
162
162
|
|
|
163
|
-
class
|
|
163
|
+
class Constraint:
|
|
164
164
|
def __init__(self, fn: Callable[[Any], Any] | None = None) -> None: ...
|
|
165
165
|
def __call__(self, value: Any) -> None: ...
|
|
166
166
|
|
|
167
167
|
@final
|
|
168
|
-
class
|
|
168
|
+
class NumericConstraint(Constraint):
|
|
169
169
|
def __init__(
|
|
170
170
|
self,
|
|
171
171
|
*,
|
|
@@ -182,7 +182,7 @@ class NumericValidator(Validator):
|
|
|
182
182
|
multiple_of: Final[int | float | None]
|
|
183
183
|
|
|
184
184
|
@final
|
|
185
|
-
class
|
|
185
|
+
class StrConstraint(Constraint):
|
|
186
186
|
def __init__(
|
|
187
187
|
self,
|
|
188
188
|
*,
|
|
@@ -195,7 +195,7 @@ class StrValidator(Validator):
|
|
|
195
195
|
max_length: Final[int | None]
|
|
196
196
|
|
|
197
197
|
@final
|
|
198
|
-
class
|
|
198
|
+
class BytesConstraint(Constraint):
|
|
199
199
|
def __init__(
|
|
200
200
|
self,
|
|
201
201
|
*,
|
|
@@ -206,7 +206,7 @@ class BytesValidator(Validator):
|
|
|
206
206
|
max_length: Final[int | None]
|
|
207
207
|
|
|
208
208
|
@final
|
|
209
|
-
class
|
|
209
|
+
class CollectionConstraint(Constraint):
|
|
210
210
|
def __init__(
|
|
211
211
|
self,
|
|
212
212
|
*,
|
|
@@ -217,7 +217,7 @@ class CollectionValidator(Validator):
|
|
|
217
217
|
max_length: Final[int | None]
|
|
218
218
|
|
|
219
219
|
@final
|
|
220
|
-
class
|
|
220
|
+
class TimezoneConstraint(Constraint):
|
|
221
221
|
def __init__(self, *, tz: bool) -> None: ...
|
|
222
222
|
tz: Final[bool]
|
|
223
223
|
|