Skip to content

Commit 44129fa

Browse files
authored
support recursive types and unions of containers, improve error messages (#4)
1 parent 5177f31 commit 44129fa

5 files changed

Lines changed: 410 additions & 139 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Added
11+
12+
- Added support for decoding recursive types, i.e. classes that take arguments which are or contain instances of the same class.
13+
14+
### Changed
15+
16+
- `decode()` failures now raise a `DecodeError`. This is a subclass of `TypeError`, which keeps things backwards compatible
17+
for the most part, except when unknown top-level fields are encountered, which used to raise an `AttributeError`.
18+
19+
### Fixed
20+
21+
- Fixed decoding a union of different dataclass types, and unions of collections.
22+
- Improved decoding error messages.
23+
1024
## [v0.2.12](https://github.com/epwalsh/dataclass-extensions/releases/tag/v0.2.12) - 2026-02-11
1125

1226
### Fixed

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ authors = [
1212
]
1313
requires-python = ">=3.10"
1414
license = { file = "LICENSE" }
15-
dependencies = []
15+
dependencies = [
16+
"typing_extensions",
17+
]
1618

1719
[project.urls]
1820
Homepage = "https://github.com/epwalsh/dataclass-extensions"

src/dataclass_extensions/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .decode import decode
1+
from .decode import DecodeError, decode
22
from .encode import encode
33
from .registrable import Registrable
44
from .types import Dataclass
@@ -7,6 +7,7 @@
77
__all__ = [
88
"Dataclass",
99
"Registrable",
10+
"DecodeError",
1011
"required_field",
1112
"encode",
1213
"decode",

0 commit comments

Comments
 (0)