structtype 0.5.0__tar.gz → 0.6.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 (56) hide show
  1. {structtype-0.5.0 → structtype-0.6.0}/AGENTS.md +7 -6
  2. {structtype-0.5.0 → structtype-0.6.0}/Makefile +17 -5
  3. {structtype-0.5.0/src/structtype.egg-info → structtype-0.6.0}/PKG-INFO +13 -4
  4. {structtype-0.5.0 → structtype-0.6.0}/README.md +8 -1
  5. {structtype-0.5.0 → structtype-0.6.0}/pyproject.toml +21 -27
  6. structtype-0.6.0/src/structtype/__init__.py +42 -0
  7. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/__init__.pyi +36 -36
  8. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/_adapter.py +1 -32
  9. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/_core.c +139 -607
  10. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/_inspect.py +28 -28
  11. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/_json_schema.py +15 -14
  12. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/_utils.py +23 -21
  13. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/_version.py +2 -2
  14. {structtype-0.5.0 → structtype-0.6.0/src/structtype.egg-info}/PKG-INFO +13 -4
  15. {structtype-0.5.0 → structtype-0.6.0}/src/structtype.egg-info/SOURCES.txt +7 -1
  16. {structtype-0.5.0 → structtype-0.6.0}/tests/test_adapter.py +107 -0
  17. structtype-0.6.0/tests/test_attrs.py +52 -0
  18. {structtype-0.5.0 → structtype-0.6.0}/tests/test_free_threading.py +45 -0
  19. {structtype-0.5.0 → structtype-0.6.0}/tests/test_inspect.py +50 -6
  20. {structtype-0.5.0 → structtype-0.6.0}/tests/test_json.py +4 -269
  21. {structtype-0.5.0 → structtype-0.6.0}/tests/test_memory.py +0 -20
  22. {structtype-0.5.0 → structtype-0.6.0}/tests/test_pydantic.py +33 -0
  23. {structtype-0.5.0 → structtype-0.6.0}/tests/test_schema.py +38 -1
  24. {structtype-0.5.0 → structtype-0.6.0}/tests/test_struct.py +68 -178
  25. structtype-0.6.0/tests/test_typecheck.py +51 -0
  26. structtype-0.6.0/tests/typecheck/api.py +62 -0
  27. structtype-0.6.0/tests/typecheck/basic.py +63 -0
  28. structtype-0.6.0/tests/typecheck/fields.py +47 -0
  29. structtype-0.6.0/tests/typecheck/types.py +100 -0
  30. {structtype-0.5.0 → structtype-0.6.0}/uv.lock +169 -167
  31. structtype-0.5.0/src/structtype/__init__.py +0 -19
  32. {structtype-0.5.0 → structtype-0.6.0}/.opencode/opencode.json +0 -0
  33. {structtype-0.5.0 → structtype-0.6.0}/.opencode/plugins/graphify.js +0 -0
  34. {structtype-0.5.0 → structtype-0.6.0}/LICENSE +0 -0
  35. {structtype-0.5.0 → structtype-0.6.0}/MANIFEST.in +0 -0
  36. {structtype-0.5.0 → structtype-0.6.0}/setup.cfg +0 -0
  37. {structtype-0.5.0 → structtype-0.6.0}/setup.py +0 -0
  38. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/atof.h +0 -0
  39. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/atof_consts.h +0 -0
  40. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/common.h +0 -0
  41. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/itoa.h +0 -0
  42. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/py.typed +0 -0
  43. {structtype-0.5.0 → structtype-0.6.0}/src/structtype/ryu.h +0 -0
  44. {structtype-0.5.0 → structtype-0.6.0}/src/structtype.egg-info/dependency_links.txt +0 -0
  45. {structtype-0.5.0 → structtype-0.6.0}/src/structtype.egg-info/top_level.txt +0 -0
  46. {structtype-0.5.0 → structtype-0.6.0}/tests/__init__.py +0 -0
  47. {structtype-0.5.0 → structtype-0.6.0}/tests/conftest.py +0 -0
  48. {structtype-0.5.0 → structtype-0.6.0}/tests/test_JSONTestSuite.py +0 -0
  49. {structtype-0.5.0 → structtype-0.6.0}/tests/test_check.py +0 -0
  50. {structtype-0.5.0 → structtype-0.6.0}/tests/test_constraints.py +0 -0
  51. {structtype-0.5.0 → structtype-0.6.0}/tests/test_cpylint.py +0 -0
  52. {structtype-0.5.0 → structtype-0.6.0}/tests/test_msgspec.py +0 -0
  53. {structtype-0.5.0 → structtype-0.6.0}/tests/test_raw.py +0 -0
  54. {structtype-0.5.0 → structtype-0.6.0}/tests/test_struct_meta.py +0 -0
  55. {structtype-0.5.0 → structtype-0.6.0}/tests/test_utils.py +0 -0
  56. {structtype-0.5.0 → structtype-0.6.0}/tests/utils.py +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`, ~20K lines).
6
+ Core is a monolithic C extension (`src/structtype/_core.c`, ~19K lines).
7
7
  No runtime deps.
8
8
 
9
9
  ## Setup
@@ -47,11 +47,11 @@ All commands go through `make`.
47
47
 
48
48
  ### Struct Methods
49
49
 
50
- - `obj.struct_dump_json(*, enc_hook=None, decimal_format=None, uuid_format=None, order=None)` — serialize to JSON bytes
51
- - `obj.struct_dump()` — convert to built-in Python types (uses `encode_name` for keys)
50
+ - `obj.struct_dump_json(*, decimal_format=None, uuid_format=None, sort_keys=False)` — serialize to JSON bytes
51
+ - `obj.struct_dump(*, sort_keys=False, str_keys=False, builtin_types=None)` — convert to built-in Python types (uses `alias` for keys)
52
52
  - `obj.struct_validate_self()` — validate field values against types + constraints
53
- - `cls.struct_validate_json(buf, *, strict=True, dec_hook=None)` — deserialize from JSON
54
- - `cls.struct_validate(obj, *, strict=True, from_attributes=False, dec_hook=None)` — convert built-in types to struct
53
+ - `cls.struct_validate_json(buf, *, strict=True)` — deserialize from JSON
54
+ - `cls.struct_validate(obj, *, strict=True, from_attributes=False)` — convert built-in types to struct
55
55
 
56
56
  ### Dict & Iteration Protocol
57
57
 
@@ -61,7 +61,8 @@ Struct instances support the mapping protocol:
61
61
 
62
62
  ## Gotchas
63
63
 
64
- - `make test-lf` reinstalls the C extension before running (last-failed first)
64
+ - `make test-cov` reinstalls the C extension before running (last-failed first)
65
+ - 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.
65
66
 
66
67
  ## graphify
67
68
 
@@ -34,11 +34,17 @@ test-lf: ## Run tests in current Python
34
34
  test-doc: ## Run doctests
35
35
  uv run pytest --doctest-modules --pyargs structtype
36
36
 
37
- .PHONY: test-all
38
- test-all: ## Run tests in all supporte Python versions
39
- for py_v in $(PY_VERSIONS); do \
40
- uv run --isolated --reinstall-package structtype -p $$py_v pytest; \
41
- done
37
+ TEST_ALL_TARGETS = $(PY_VERSIONS:%=test-all-%)
38
+
39
+ .PHONY: test-all $(TEST_ALL_TARGETS)
40
+ test-all: $(TEST_ALL_TARGETS) ## Run tests in all supported Python versions (parallel: make -j$(nproc) test-all)
41
+
42
+ define test-all-rule
43
+ .PHONY: test-all-$(1)
44
+ test-all-$(1): ## Run tests for Python $(1)
45
+ uv run --isolated --reinstall-package structtype -p $(1) pytest
46
+ endef
47
+ $(foreach py_v,$(PY_VERSIONS),$(eval $(call test-all-rule,$(py_v))))
42
48
 
43
49
  UNAME_S := $(shell uname -s)
44
50
  ifeq ($(UNAME_S),Darwin)
@@ -74,6 +80,12 @@ type-check: ## Type check with
74
80
  -uvx ty check ${SOURCE_DIR}
75
81
  uvx pyrefly check ${SOURCE_DIR}
76
82
 
83
+ .PHONY: typecheck-tests
84
+ typecheck-tests: ## Type check tests/typecheck fixtures (skipped when tools unavailable)
85
+ @if uvx ty --version >/dev/null 2>&1; then uvx ty check tests/typecheck; else echo "skip: ty unavailable"; fi
86
+ @if uvx pyrefly --version >/dev/null 2>&1; then uvx pyrefly check tests/typecheck; else echo "skip: pyrefly unavailable"; fi
87
+ @if uvx mypy --version >/dev/null 2>&1; then uvx mypy --python-executable .venv/bin/python tests/typecheck; else echo "skip: mypy unavailable"; fi
88
+
77
89
  .PHONY: format
78
90
  format: ## Format files using ruff format
79
91
  uvx ruff format ${SOURCE_DIR}
@@ -1,12 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: structtype
3
- Version: 0.5.0
3
+ Version: 0.6.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
7
- Project-URL: Homepage, https://github.com/tds333/structtype
7
+ Project-URL: Homepage, https://tds333.github.io/structtype/
8
+ Project-URL: Documentation, https://tds333.github.io/structtype/
9
+ Project-URL: Repository, https://github.com/tds333/structtype
10
+ Project-URL: Changelog, https://tds333.github.io/structtype/changelog.html
8
11
  Project-URL: Issue Tracker, https://github.com/tds333/structtype/issues
9
- Project-URL: Source, https://github.com/tds333/structtype
10
12
  Keywords: JSON,schema,serialization,struct,validation
11
13
  Classifier: Development Status :: 4 - Beta
12
14
  Classifier: Environment :: WebAssembly :: Emscripten
@@ -23,7 +25,11 @@ Dynamic: license-file
23
25
 
24
26
  # structtype
25
27
 
26
- Fast Struct type with validation + JSON serialization for Python.
28
+ [![PyPI version](https://img.shields.io/pypi/v/structtype)](https://pypi.org/project/structtype/)
29
+ [![Python versions](https://img.shields.io/pypi/pyversions/structtype)](https://pypi.org/project/structtype/)
30
+ [![Build status](https://img.shields.io/github/actions/workflow/status/tds333/structtype/build.yml?branch=main)](https://github.com/tds333/structtype/actions/workflows/build.yml)
31
+
32
+ Fast data struct type with validation + JSON serialization for Python.
27
33
 
28
34
  - **High performance** — 5-60x faster than dataclasses, attrs, or pydantic for common operations
29
35
  - **Schema validation** — familiar Python type annotations, enforced at decode time
@@ -77,8 +83,11 @@ structtype is as fast as msgspec and about 3-5x faster than pydantic. See the
77
83
 
78
84
  ## Links
79
85
 
86
+ - [Documentation](https://tds333.github.io/structtype/)
80
87
  - [Changelog](https://tds333.github.io/structtype/changelog.html)
88
+ - [PyPI](https://pypi.org/project/structtype/)
81
89
  - [Source code](https://github.com/tds333/structtype)
90
+ - [Issue tracker](https://github.com/tds333/structtype/issues)
82
91
 
83
92
  ## License
84
93
 
@@ -1,6 +1,10 @@
1
1
  # structtype
2
2
 
3
- Fast Struct type with validation + JSON serialization for Python.
3
+ [![PyPI version](https://img.shields.io/pypi/v/structtype)](https://pypi.org/project/structtype/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/structtype)](https://pypi.org/project/structtype/)
5
+ [![Build status](https://img.shields.io/github/actions/workflow/status/tds333/structtype/build.yml?branch=main)](https://github.com/tds333/structtype/actions/workflows/build.yml)
6
+
7
+ Fast data struct type with validation + JSON serialization for Python.
4
8
 
5
9
  - **High performance** — 5-60x faster than dataclasses, attrs, or pydantic for common operations
6
10
  - **Schema validation** — familiar Python type annotations, enforced at decode time
@@ -54,8 +58,11 @@ structtype is as fast as msgspec and about 3-5x faster than pydantic. See the
54
58
 
55
59
  ## Links
56
60
 
61
+ - [Documentation](https://tds333.github.io/structtype/)
57
62
  - [Changelog](https://tds333.github.io/structtype/changelog.html)
63
+ - [PyPI](https://pypi.org/project/structtype/)
58
64
  - [Source code](https://github.com/tds333/structtype)
65
+ - [Issue tracker](https://github.com/tds333/structtype/issues)
59
66
 
60
67
  ## License
61
68
 
@@ -4,19 +4,9 @@ description = "Fast Struct type with validation and JSON serialization for Pytho
4
4
  readme = "README.md"
5
5
  requires-python = ">=3.10"
6
6
  license = "BSD-3-Clause"
7
- license-files = [
8
- "LICENSE",
9
- ]
10
- maintainers = [
11
- { name = "Wolfgang Langner", email = "tds333@mailbox.org" },
12
- ]
13
- keywords = [
14
- "JSON",
15
- "schema",
16
- "serialization",
17
- "struct",
18
- "validation",
19
- ]
7
+ license-files = ["LICENSE"]
8
+ maintainers = [{ name = "Wolfgang Langner", email = "tds333@mailbox.org" }]
9
+ keywords = ["JSON", "schema", "serialization", "struct", "validation"]
20
10
  classifiers = [
21
11
  "Development Status :: 4 - Beta",
22
12
  "Environment :: WebAssembly :: Emscripten",
@@ -28,23 +18,24 @@ classifiers = [
28
18
  "Programming Language :: Python :: 3.15",
29
19
  ]
30
20
  dependencies = []
31
- dynamic = [
32
- "version",
33
- ]
21
+ dynamic = ["version"]
34
22
 
35
23
  [project.urls]
36
- Homepage = "https://github.com/tds333/structtype"
24
+ Homepage = "https://tds333.github.io/structtype/"
25
+ Documentation = "https://tds333.github.io/structtype/"
26
+ Repository = "https://github.com/tds333/structtype"
27
+ Changelog = "https://tds333.github.io/structtype/changelog.html"
37
28
  "Issue Tracker" = "https://github.com/tds333/structtype/issues"
38
- Source = "https://github.com/tds333/structtype"
39
29
 
40
30
  [dependency-groups]
41
31
  dev = [
42
32
  "attrs",
43
33
  "coverage",
44
34
  "msgspec",
45
- "pydantic; python_version < '3.15'",
35
+ "pydantic; python_version < '3.16'",
46
36
  "pytest>=9",
47
37
  "pytest-coverage>=0.0",
38
+ "typing_extensions",
48
39
  ]
49
40
  docs = [
50
41
  "furo",
@@ -56,10 +47,7 @@ docs = [
56
47
  ]
57
48
 
58
49
  [build-system]
59
- requires = [
60
- "setuptools>=80",
61
- "setuptools-scm>=8",
62
- ]
50
+ requires = ["setuptools>=80", "setuptools-scm>=8"]
63
51
  build-backend = "setuptools.build_meta"
64
52
 
65
53
  [tool.setuptools]
@@ -69,10 +57,7 @@ packages = ["structtype"]
69
57
  "" = "src"
70
58
 
71
59
  [tool.setuptools.exclude-package-data]
72
- structtype = [
73
- "*.c",
74
- "*.h",
75
- ]
60
+ structtype = ["*.c", "*.h"]
76
61
 
77
62
  [tool.setuptools_scm]
78
63
  version_file = "src/structtype/_version.py"
@@ -88,3 +73,12 @@ test-command = "pip install pytest>=9 && pytest {project}/tests"
88
73
 
89
74
  [tool.ruff]
90
75
  target-version = "py310"
76
+
77
+ [tool.coverage.report]
78
+ exclude_lines = [
79
+ 'pragma: no cover',
80
+ 'if (typing\.)?TYPE_CHECKING:',
81
+ 'if sys\.version_info',
82
+ 'except ImportError:',
83
+ '# noqa: F821',
84
+ ]
@@ -0,0 +1,42 @@
1
+ from ._adapter import StructAdapter
2
+ from ._core import ( # type: ignore
3
+ ALL_BUILTIN_TYPES,
4
+ NODEFAULT,
5
+ UNSET,
6
+ DecodeError,
7
+ EncodeError,
8
+ Factory,
9
+ Field,
10
+ Raw,
11
+ Struct,
12
+ StructConfig,
13
+ StructMeta,
14
+ UnsetType,
15
+ ValidationError,
16
+ )
17
+ from ._inspect import FieldInfo, fields
18
+ from ._json_schema import json_schema, json_schema_components, json_schema_dump
19
+ from ._version import __version__
20
+
21
+ __all__ = [
22
+ "ALL_BUILTIN_TYPES",
23
+ "NODEFAULT",
24
+ "UNSET",
25
+ "DecodeError",
26
+ "EncodeError",
27
+ "Factory",
28
+ "Field",
29
+ "FieldInfo",
30
+ "Raw",
31
+ "Struct",
32
+ "StructAdapter",
33
+ "StructConfig",
34
+ "StructMeta",
35
+ "UnsetType",
36
+ "ValidationError",
37
+ "__version__",
38
+ "fields",
39
+ "json_schema",
40
+ "json_schema_components",
41
+ "json_schema_dump",
42
+ ]
@@ -1,11 +1,34 @@
1
+ # ruff: noqa: PYI041, PYI015, PYI020, UP037
1
2
  import enum
2
3
  from collections.abc import Callable, Iterable, Iterator, Mapping
3
4
  from inspect import Signature
4
- from typing import Any, ClassVar, Final, Literal, TypeAlias, TypeVar, final, overload
5
+ from typing import (
6
+ Any,
7
+ ClassVar,
8
+ Final,
9
+ Literal,
10
+ TypeAlias,
11
+ TypeVar,
12
+ final,
13
+ overload,
14
+ )
5
15
 
6
16
  from typing_extensions import Buffer, Self, dataclass_transform
7
17
 
8
- from . import StructConfig
18
+ class StructConfig:
19
+ frozen: bool
20
+ eq: bool
21
+ order: bool
22
+ array_like: bool
23
+ repr_omit_defaults: bool
24
+ omit_defaults: bool
25
+ forbid_unknown_fields: bool
26
+ validate_on_init: bool
27
+ weakref: bool
28
+ dict: bool
29
+ cache_hash: bool
30
+ tag: str | int | None
31
+ tag_field: str | None
9
32
 
10
33
  # PEP 673 explicitly rejects using Self in metaclass definitions:
11
34
  # https://peps.python.org/pep-0673/#valid-locations-for-self
@@ -17,8 +40,8 @@ _SM = TypeVar("_SM", bound="StructMeta")
17
40
  class StructMeta(type):
18
41
  __struct_fields__: ClassVar[tuple[str, ...]]
19
42
  __struct_defaults__: ClassVar[tuple[Any, ...]]
20
- __struct_encode_fields__: ClassVar[tuple[str, ...]]
21
- __match_args__: ClassVar[tuple[str, ...]]
43
+ __struct_alias_fields__: ClassVar[tuple[str, ...]]
44
+ __match_args__: ClassVar[tuple[str, ...]] = ...
22
45
  @property
23
46
  def __signature__(self) -> Signature: ...
24
47
  @property
@@ -46,15 +69,12 @@ class StructMeta(type):
46
69
  kw_only: bool = False,
47
70
  repr_omit_defaults: bool = False,
48
71
  array_like: bool = False,
49
- gc: bool = True,
50
72
  weakref: bool = False,
51
73
  dict: bool = False,
52
74
  cache_hash: bool = False,
53
75
  validate_on_init: bool = False,
54
76
  ) -> _SM: ...
55
77
 
56
- _T = TypeVar("_T")
57
-
58
78
  @final
59
79
  class UnsetType(enum.Enum):
60
80
  UNSET = "UNSET"
@@ -68,13 +88,13 @@ class _NoDefault(enum.Enum):
68
88
 
69
89
  NODEFAULT: Final = _NoDefault.NODEFAULT
70
90
 
71
- @dataclass_transform(field_specifiers=("Field",))
91
+ @dataclass_transform(field_specifiers=("Field",)) # type: ignore
72
92
  class Struct(metaclass=StructMeta):
73
93
  __struct_fields__: ClassVar[tuple[str, ...]]
74
94
  __struct_config__: ClassVar[StructConfig]
75
- __struct_encode_fields__: ClassVar[tuple[str, ...]]
95
+ __struct_alias_fields__: ClassVar[tuple[str, ...]]
76
96
  __struct_defaults__: ClassVar[tuple[Any, ...]]
77
- __match_args__: ClassVar[tuple[str, ...]]
97
+ __match_args__: ClassVar[tuple[str, ...]] = ...
78
98
  # A default __init__ so that Structs with unknown field types
79
99
  # won't error on every call to `__init__`
80
100
  def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@@ -96,7 +116,6 @@ class Struct(metaclass=StructMeta):
96
116
  kw_only: bool = False,
97
117
  repr_omit_defaults: bool = False,
98
118
  array_like: bool = False,
99
- gc: bool = True,
100
119
  weakref: bool = False,
101
120
  dict: bool = False,
102
121
  cache_hash: bool = False,
@@ -126,19 +145,19 @@ class Struct(metaclass=StructMeta):
126
145
  def struct_validate_self(self) -> None: ...
127
146
  @classmethod
128
147
  def struct_validate_json(
129
- cls: type[_T],
148
+ cls,
130
149
  buf: str | Buffer,
131
150
  *,
132
151
  strict: bool = True,
133
- ) -> _T: ...
152
+ ) -> Self: ...
134
153
  @classmethod
135
154
  def struct_validate(
136
- cls: type[_T],
155
+ cls,
137
156
  obj: Any,
138
157
  *,
139
158
  strict: bool = True,
140
159
  from_attributes: bool = False,
141
- ) -> _T: ...
160
+ ) -> Self: ...
142
161
 
143
162
  # Lie and say `Raw` is a subclass of `bytes`, so mypy will accept it in most
144
163
  # places where an object that implements the buffer protocol is valid
@@ -155,7 +174,7 @@ _NonNegativeInt: TypeAlias = int
155
174
 
156
175
  @final
157
176
  class Factory:
158
- def __init__(self, factory: Callable[[], Any]) -> None: ...
177
+ def __new__(cls, factory: Callable[[], Any]) -> Any: ...
159
178
  factory: Final[Callable[[], Any]]
160
179
 
161
180
  @final
@@ -262,25 +281,9 @@ class Field:
262
281
  validate: Final[Callable[[Any], Any] | None]
263
282
  def __rich_repr__(self) -> list[tuple[str, Any]]: ...
264
283
 
265
- class StructConfig:
266
- frozen: bool
267
- eq: bool
268
- order: bool
269
- array_like: bool
270
- gc: bool
271
- repr_omit_defaults: bool
272
- omit_defaults: bool
273
- forbid_unknown_fields: bool
274
- validate_on_init: bool
275
- weakref: bool
276
- dict: bool
277
- cache_hash: bool
278
- tag: str | int | None
279
- tag_field: str | None
280
-
281
284
  class FieldInfo(Struct):
282
285
  name: str
283
- encode_name: str
286
+ alias: str
284
287
  type: Any
285
288
  default: Any = NODEFAULT
286
289
  default_factory: Any = NODEFAULT
@@ -342,9 +345,6 @@ class StructAdapter:
342
345
  builtin_types: Iterable[type] | None = None,
343
346
  ) -> Any: ...
344
347
 
345
- class StrAdapter:
346
- def __new__(cls, type: type[Any]) -> type[str]: ...
347
-
348
348
  class EncodeError(ValueError): ...
349
349
  class DecodeError(ValueError): ...
350
350
  class ValidationError(ValueError): ...
@@ -3,7 +3,7 @@ from typing import Any, get_args
3
3
  from ._core import ( # type: ignore
4
4
  Field as _Field,
5
5
  )
6
- from ._core import (
6
+ from ._core import ( # type: ignore
7
7
  _dump,
8
8
  _json_decode,
9
9
  _json_encode,
@@ -131,34 +131,3 @@ class StructAdapter:
131
131
  str_keys=str_keys,
132
132
  sort_keys=sort_keys,
133
133
  )
134
-
135
-
136
- class StrAdapter:
137
- """Create a ``str`` subclass wrapper for validating a type during
138
- structtype serialization.
139
-
140
- Wraps a type that has a single-argument string constructor
141
- (e.g. ``HttpUrl``, ``EmailStr``, ``IPv4Address``) into a ``str``
142
- subclass. The wrapped value is stored as a string but validated by
143
- calling ``typ(value)`` on construction. During structtype
144
- validation and serialization, the wrapper is treated as a native
145
- ``str``.
146
-
147
- >>> from structtype import StrAdapter, Struct
148
- >>> from ipaddress import IPv4Address
149
- >>>
150
- >>> class Config(Struct):
151
- ... ip: StrAdapter(IPv4Address)
152
- """
153
-
154
- __slots__ = ()
155
-
156
- def __new__(cls, typ):
157
- return type(
158
- f"_Wrapped_{typ.__name__}",
159
- (str,),
160
- {
161
- "__slots__": (),
162
- "__new__": lambda self, v: str.__new__(self, str(typ(v))),
163
- },
164
- )