structtype 0.12.0__tar.gz → 0.14.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.14.0/.opencode/opencode.json +4 -0
- {structtype-0.12.0 → structtype-0.14.0}/AGENTS.md +11 -14
- {structtype-0.12.0 → structtype-0.14.0}/Makefile +9 -0
- {structtype-0.12.0/src/structtype.egg-info → structtype-0.14.0}/PKG-INFO +4 -2
- {structtype-0.12.0 → structtype-0.14.0}/README.md +3 -1
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/__init__.pyi +9 -1
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/_core.c +2164 -1388
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/_inspect.py +68 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/_json_schema.py +57 -15
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/_utils.py +23 -1
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/_version.py +2 -2
- {structtype-0.12.0 → structtype-0.14.0/src/structtype.egg-info}/PKG-INFO +4 -2
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype.egg-info/SOURCES.txt +3 -1
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_adapter.py +28 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_annotations.py +67 -2
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_check.py +12 -4
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_constraints.py +47 -0
- structtype-0.14.0/tests/test_csv.py +413 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_inspect.py +14 -0
- structtype-0.14.0/tests/test_ipnetwork.py +196 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_json.py +191 -0
- structtype-0.14.0/tests/test_purepath.py +155 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_roundtrip.py +16 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_schema.py +97 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_struct.py +144 -0
- structtype-0.12.0/.opencode/opencode.json +0 -6
- structtype-0.12.0/.opencode/plugins/graphify.js +0 -30
- {structtype-0.12.0 → structtype-0.14.0}/LICENSE +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/MANIFEST.in +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/pyproject.toml +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/setup.cfg +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/setup.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/__init__.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/_adapter.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/_config.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/atof.h +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/atof_consts.h +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/common.h +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/itoa.h +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/py.typed +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype/ryu.h +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype.egg-info/dependency_links.txt +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/src/structtype.egg-info/top_level.txt +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/__init__.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/conftest.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_JSONTestSuite.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_attrs.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_cpylint.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_free_threading.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_frozendict.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_memory.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_msgspec.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_pydantic.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_struct_meta.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_threading.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_typecheck.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/test_utils.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/typecheck/api.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/typecheck/basic.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/typecheck/fields.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/typecheck/types.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/tests/utils.py +0 -0
- {structtype-0.12.0 → structtype-0.14.0}/uv.lock +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## Project
|
|
4
4
|
|
|
5
5
|
Fast struct validation + JSON serialization for Python.
|
|
6
|
-
Core is a monolithic C extension (`src/structtype/_core.c`, ~
|
|
6
|
+
Core is a monolithic C extension (`src/structtype/_core.c`, ~22K lines).
|
|
7
7
|
No runtime deps.
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
@@ -25,16 +25,23 @@ Use `make` targets where available. Targeted tests can be run directly with
|
|
|
25
25
|
| Coverage (Python + C) | `make test-cov-c` |
|
|
26
26
|
| Coverage (Python + C, all Pythons, merged) | `make test-cov-c-all` |
|
|
27
27
|
| Tests in all supported Pythons | `make test-all` |
|
|
28
|
+
| Doctests | `make test-doc` |
|
|
29
|
+
| Build sdist + wheel | `make build` |
|
|
28
30
|
| Build docs | `make docs` |
|
|
29
31
|
| Format | `make format` |
|
|
30
32
|
| Lint | `make ruff-check` |
|
|
31
33
|
| Type check | `make type-check` |
|
|
32
34
|
| Static checks | `make check` |
|
|
33
35
|
|
|
36
|
+
Benchmark targets: `make bench`, `make bench-validators`, `make bench-codecs`,
|
|
37
|
+
`make bench-csv-1m`, `make bench-strings` (run sequentially; CPU-bound).
|
|
38
|
+
|
|
34
39
|
## Conventions
|
|
35
40
|
|
|
36
41
|
- **88-char lines**, formatted with `ruff format`
|
|
37
|
-
- `ruff check` with
|
|
42
|
+
- `ruff check` with Ruff's default rule set (the project config sets only
|
|
43
|
+
`target-version` and isort `combine-as-imports`; line length is enforced by
|
|
44
|
+
`ruff format`, not `E501`)
|
|
38
45
|
- Private modules/functions prefixed with `_`
|
|
39
46
|
- C code uses `ms_`/`MS_` prefix
|
|
40
47
|
- Type stubs (`.pyi`) alongside public modules
|
|
@@ -59,6 +66,8 @@ Use `make` targets where available. Targeted tests can be run directly with
|
|
|
59
66
|
- `obj.struct_check_types()` — validate field values against types + constraints (pure type-check, no conversion)
|
|
60
67
|
- `cls.struct_validate_json(buf, *, strict=True)` — deserialize from JSON
|
|
61
68
|
- `cls.struct_validate(obj, *, strict=True, from_attributes=False)` — convert built-in types to struct
|
|
69
|
+
- `obj.struct_dump_csv()` — encode one row as `list[str]` for `csv.writer.writerow()`; flat scalar fields only, positional
|
|
70
|
+
- `cls.struct_validate_csv(row, *, null_values=("",))` — decode one CSV row (sequence of cell strings); always lax
|
|
62
71
|
|
|
63
72
|
### Dict & Iteration Protocol
|
|
64
73
|
|
|
@@ -75,15 +84,3 @@ Struct instances support the mapping protocol:
|
|
|
75
84
|
- Validation matches keys by the **alias** name only, except `struct_validate(obj, from_attributes=True)` on a **non-dict object**, which matches by both the python field name and the alias. Dict/JSON input (even with `from_attributes=True`) and all dump/serialization use only the alias name.
|
|
76
85
|
- For `Annotated[MyType, Serializer(load=...)]`, an existing `MyType` instance bypasses `load`; other Python values and JSON representations are passed to `load`. Serializers remain rejected on `Any`, `bool`, `int`, `float`, `str`, `list`, `dict`, `tuple`, `TypedDict`, `NamedTuple`, `frozendict`, and `Literal`. `Serializer` and `Constraint` must attach to a concrete type inside `Annotated` — `Annotated[Union[A, B], ...]` and `Annotated[Optional[T], ...]` are rejected; use `Annotated[T, ...] | None` for optional fields.
|
|
77
86
|
|
|
78
|
-
## graphify
|
|
79
|
-
|
|
80
|
-
This project has a knowledge graph at graphify-out/ with god nodes, community structure, and cross-file relationships.
|
|
81
|
-
|
|
82
|
-
When the user types `/graphify`, use the installed graphify skill or instructions before doing anything else.
|
|
83
|
-
|
|
84
|
-
Rules:
|
|
85
|
-
- For codebase questions, first run `graphify query "<question>"` when graphify-out/graph.json exists. Use `graphify path "<A>" "<B>"` for relationships and `graphify explain "<concept>"` for focused concepts. These return a scoped subgraph, usually much smaller than GRAPH_REPORT.md or raw grep output.
|
|
86
|
-
- Dirty graphify-out/ files are expected after hooks or incremental updates; dirty graph files are not a reason to skip graphify. Only skip graphify if the task is about stale or incorrect graph output, or the user explicitly says not to use it.
|
|
87
|
-
- If graphify-out/wiki/index.md exists, use it for broad navigation instead of raw source browsing.
|
|
88
|
-
- Read graphify-out/GRAPH_REPORT.md only for broad architecture review or when query/path/explain do not surface enough context.
|
|
89
|
-
- After modifying code, run `graphify update .` to keep the graph current (AST-only, no API cost).
|
|
@@ -143,6 +143,14 @@ bench-validators: ## run Serializer/Validator benchmarks
|
|
|
143
143
|
bench-codecs: ## run Constraint + Serializer heavy benchmarks
|
|
144
144
|
uv run -p 3.15 benchmarks/bench_codecs.py
|
|
145
145
|
|
|
146
|
+
.PHONY: bench-csv-1m
|
|
147
|
+
bench-csv-1m: ## run 1M-row on-disk CSV benchmark
|
|
148
|
+
uv run -p 3.15 benchmarks/bench_csv_1m.py
|
|
149
|
+
|
|
150
|
+
.PHONY: bench-strings
|
|
151
|
+
bench-strings: ## run long-string JSON codec benchmark
|
|
152
|
+
uv run -p 3.15 benchmarks/bench_strings.py
|
|
153
|
+
|
|
146
154
|
##@ Utility
|
|
147
155
|
.PHONY: clean
|
|
148
156
|
clean: ## Delete all temporary files
|
|
@@ -157,6 +165,7 @@ clean: ## Delete all temporary files
|
|
|
157
165
|
rm -rf htmlcov-c
|
|
158
166
|
rm -f .coverage
|
|
159
167
|
rm -f coverage-c.info coverage-c.info.*
|
|
168
|
+
rm -rf .venv*
|
|
160
169
|
|
|
161
170
|
.PHONY: install
|
|
162
171
|
install: install-uv ## Install virtual environment
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: structtype
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.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
|
|
@@ -77,6 +77,8 @@ User.struct_validate_json(
|
|
|
77
77
|
|
|
78
78
|
Full documentation is available at **https://tds333.github.io/structtype/**.
|
|
79
79
|
|
|
80
|
+
The library is in beta phase, interface and features may have breaking changes.
|
|
81
|
+
|
|
80
82
|
## Benchmarks
|
|
81
83
|
|
|
82
84
|
structtype is as fast as msgspec and about 3-5x faster than pydantic. See the
|
|
@@ -93,4 +95,4 @@ structtype is as fast as msgspec and about 3-5x faster than pydantic. See the
|
|
|
93
95
|
## License
|
|
94
96
|
|
|
95
97
|
New BSD. See the [License File](LICENSE).
|
|
96
|
-
|
|
98
|
+
Parts of the core are based on the work of Jim Crist-Harif from msgspec.
|
|
@@ -51,6 +51,8 @@ User.struct_validate_json(
|
|
|
51
51
|
|
|
52
52
|
Full documentation is available at **https://tds333.github.io/structtype/**.
|
|
53
53
|
|
|
54
|
+
The library is in beta phase, interface and features may have breaking changes.
|
|
55
|
+
|
|
54
56
|
## Benchmarks
|
|
55
57
|
|
|
56
58
|
structtype is as fast as msgspec and about 3-5x faster than pydantic. See the
|
|
@@ -67,4 +69,4 @@ structtype is as fast as msgspec and about 3-5x faster than pydantic. See the
|
|
|
67
69
|
## License
|
|
68
70
|
|
|
69
71
|
New BSD. See the [License File](LICENSE).
|
|
70
|
-
|
|
72
|
+
Parts of the core are based on the work of Jim Crist-Harif from msgspec.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ruff: noqa: PYI041, PYI015
|
|
2
2
|
import enum
|
|
3
|
-
from collections.abc import Callable, Iterable, Iterator, Mapping
|
|
3
|
+
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
|
|
4
4
|
from inspect import Signature
|
|
5
5
|
from typing import (
|
|
6
6
|
Any,
|
|
@@ -85,6 +85,7 @@ class Struct(metaclass=StructMeta):
|
|
|
85
85
|
uuid_as_hex: bool = False,
|
|
86
86
|
sort_keys: bool = False,
|
|
87
87
|
) -> bytes: ...
|
|
88
|
+
def struct_dump_csv(self) -> list[str]: ...
|
|
88
89
|
def struct_dump(
|
|
89
90
|
self,
|
|
90
91
|
*,
|
|
@@ -101,6 +102,13 @@ class Struct(metaclass=StructMeta):
|
|
|
101
102
|
strict: bool = True,
|
|
102
103
|
) -> Self: ...
|
|
103
104
|
@classmethod
|
|
105
|
+
def struct_validate_csv(
|
|
106
|
+
cls,
|
|
107
|
+
row: Sequence[str],
|
|
108
|
+
*,
|
|
109
|
+
null_values: Sequence[str] = ("",),
|
|
110
|
+
) -> Self: ...
|
|
111
|
+
@classmethod
|
|
104
112
|
def struct_validate(
|
|
105
113
|
cls,
|
|
106
114
|
obj: Any,
|