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.
Files changed (58) hide show
  1. {structtype-0.8.1 → structtype-0.9.0}/AGENTS.md +4 -2
  2. {structtype-0.8.1/src/structtype.egg-info → structtype-0.9.0}/PKG-INFO +1 -1
  3. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/__init__.py +12 -12
  4. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/__init__.pyi +8 -8
  5. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_config.py +1 -1
  6. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_core.c +462 -372
  7. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_inspect.py +6 -6
  8. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_version.py +2 -2
  9. {structtype-0.8.1 → structtype-0.9.0/src/structtype.egg-info}/PKG-INFO +1 -1
  10. {structtype-0.8.1 → structtype-0.9.0}/tests/test_adapter.py +5 -5
  11. {structtype-0.8.1 → structtype-0.9.0}/tests/test_annotations.py +237 -237
  12. structtype-0.9.0/tests/test_check.py +389 -0
  13. {structtype-0.8.1 → structtype-0.9.0}/tests/test_constraints.py +91 -91
  14. {structtype-0.8.1 → structtype-0.9.0}/tests/test_inspect.py +15 -15
  15. {structtype-0.8.1 → structtype-0.9.0}/tests/test_json.py +3 -3
  16. {structtype-0.8.1 → structtype-0.9.0}/tests/test_schema.py +17 -17
  17. {structtype-0.8.1 → structtype-0.9.0}/tests/test_struct_meta.py +2 -2
  18. {structtype-0.8.1 → structtype-0.9.0}/tests/typecheck/basic.py +1 -1
  19. {structtype-0.8.1 → structtype-0.9.0}/tests/typecheck/fields.py +7 -7
  20. structtype-0.8.1/tests/test_check.py +0 -270
  21. {structtype-0.8.1 → structtype-0.9.0}/.opencode/opencode.json +0 -0
  22. {structtype-0.8.1 → structtype-0.9.0}/.opencode/plugins/graphify.js +0 -0
  23. {structtype-0.8.1 → structtype-0.9.0}/LICENSE +0 -0
  24. {structtype-0.8.1 → structtype-0.9.0}/MANIFEST.in +0 -0
  25. {structtype-0.8.1 → structtype-0.9.0}/Makefile +0 -0
  26. {structtype-0.8.1 → structtype-0.9.0}/README.md +0 -0
  27. {structtype-0.8.1 → structtype-0.9.0}/pyproject.toml +0 -0
  28. {structtype-0.8.1 → structtype-0.9.0}/setup.cfg +0 -0
  29. {structtype-0.8.1 → structtype-0.9.0}/setup.py +0 -0
  30. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_adapter.py +0 -0
  31. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_json_schema.py +0 -0
  32. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/_utils.py +0 -0
  33. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/atof.h +0 -0
  34. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/atof_consts.h +0 -0
  35. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/common.h +0 -0
  36. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/itoa.h +0 -0
  37. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/py.typed +0 -0
  38. {structtype-0.8.1 → structtype-0.9.0}/src/structtype/ryu.h +0 -0
  39. {structtype-0.8.1 → structtype-0.9.0}/src/structtype.egg-info/SOURCES.txt +0 -0
  40. {structtype-0.8.1 → structtype-0.9.0}/src/structtype.egg-info/dependency_links.txt +0 -0
  41. {structtype-0.8.1 → structtype-0.9.0}/src/structtype.egg-info/top_level.txt +0 -0
  42. {structtype-0.8.1 → structtype-0.9.0}/tests/__init__.py +0 -0
  43. {structtype-0.8.1 → structtype-0.9.0}/tests/conftest.py +0 -0
  44. {structtype-0.8.1 → structtype-0.9.0}/tests/test_JSONTestSuite.py +0 -0
  45. {structtype-0.8.1 → structtype-0.9.0}/tests/test_attrs.py +0 -0
  46. {structtype-0.8.1 → structtype-0.9.0}/tests/test_cpylint.py +0 -0
  47. {structtype-0.8.1 → structtype-0.9.0}/tests/test_free_threading.py +0 -0
  48. {structtype-0.8.1 → structtype-0.9.0}/tests/test_memory.py +0 -0
  49. {structtype-0.8.1 → structtype-0.9.0}/tests/test_msgspec.py +0 -0
  50. {structtype-0.8.1 → structtype-0.9.0}/tests/test_pydantic.py +0 -0
  51. {structtype-0.8.1 → structtype-0.9.0}/tests/test_raw.py +0 -0
  52. {structtype-0.8.1 → structtype-0.9.0}/tests/test_struct.py +0 -0
  53. {structtype-0.8.1 → structtype-0.9.0}/tests/test_typecheck.py +0 -0
  54. {structtype-0.8.1 → structtype-0.9.0}/tests/test_utils.py +0 -0
  55. {structtype-0.8.1 → structtype-0.9.0}/tests/typecheck/api.py +0 -0
  56. {structtype-0.8.1 → structtype-0.9.0}/tests/typecheck/types.py +0 -0
  57. {structtype-0.8.1 → structtype-0.9.0}/tests/utils.py +0 -0
  58. {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 constraints (gt, ge, lt, le, min_length, etc.)
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.struct_validate_self()` — validate field values against types + constraints
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: structtype
3
- Version: 0.8.1
3
+ Version: 0.9.0
4
4
  Summary: Fast Struct type with validation and JSON serialization for Python.
5
5
  Maintainer-email: Wolfgang Langner <tds333@mailbox.org>
6
6
  License-Expression: BSD-3-Clause
@@ -4,22 +4,22 @@ from ._core import ( # type: ignore
4
4
  ALL_BUILTIN_TYPES,
5
5
  NODEFAULT,
6
6
  UNSET,
7
- BytesValidator,
8
- CollectionValidator,
7
+ BytesConstraint,
8
+ CollectionConstraint,
9
+ Constraint,
9
10
  DecodeError,
10
11
  EncodeError,
11
12
  Factory,
12
13
  Field,
13
- NumericValidator,
14
+ NumericConstraint,
14
15
  Raw,
15
16
  Serializer,
17
+ StrConstraint,
16
18
  Struct,
17
19
  StructMeta,
18
- StrValidator,
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
- "BytesValidator",
33
- "CollectionValidator",
32
+ "BytesConstraint",
33
+ "CollectionConstraint",
34
+ "Constraint",
34
35
  "DecodeError",
35
36
  "EncodeError",
36
37
  "Factory",
37
38
  "Field",
38
39
  "FieldInfo",
39
- "NumericValidator",
40
+ "NumericConstraint",
40
41
  "Raw",
41
42
  "Serializer",
42
- "StrValidator",
43
+ "StrConstraint",
43
44
  "Struct",
44
45
  "StructAdapter",
45
46
  "StructConfig",
46
47
  "StructMeta",
47
- "TimezoneValidator",
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
- validate_on_init: bool
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 struct_validate_self(self) -> None: ...
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 Validator:
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 NumericValidator(Validator):
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 StrValidator(Validator):
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 BytesValidator(Validator):
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 CollectionValidator(Validator):
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 TimezoneValidator(Validator):
220
+ class TimezoneConstraint(Constraint):
221
221
  def __init__(self, *, tz: bool) -> None: ...
222
222
  tz: Final[bool]
223
223
 
@@ -17,7 +17,7 @@ class StructConfig(TypedDict, total=False):
17
17
  array_like: bool
18
18
  omit_defaults: bool
19
19
  forbid_unknown_fields: bool
20
- validate_on_init: bool
20
+ check_types_on_init: bool
21
21
  weakref: bool
22
22
  dict: bool
23
23
  cache_hash: bool