Path to this page:
Subject: CVS commit: pkgsrc/devel/py-cattrs
From: Adam Ciarcinski
Date: 2024-08-30 09:18:12
Message id: 20240830071812.1F525FC74@cvs.NetBSD.org
Log Message:
py-cattrs: updated to 24.1.0
24.1.0 (2024-08-28)
- **Potentially breaking**: Unstructuring hooks for `typing.Any` are consistent \
now: values are unstructured using their runtime type.
Previously this behavior was underspecified and inconsistent, but followed \
this rule in the majority of cases.
Reverting old behavior is very dependent on the actual case; ask on the issue \
tracker if in doubt.
- **Minor change**: Heterogeneous tuples are now unstructured into tuples \
instead of lists by default; this is significantly faster and widely supported \
by serialization libraries.
- **Minor change**: {py:func}`cattrs.gen.make_dict_structure_fn` will use the \
value for the `prefer_attrib_converters` parameter from the given converter by \
default now.
If you're using this function directly, the old behavior can be restored by \
passing in the desired values explicitly.
- Introduce {meth}`BaseConverter.get_structure_hook` and \
{meth}`BaseConverter.get_unstructure_hook` methods.
- {meth}`BaseConverter.register_structure_hook`, \
{meth}`BaseConverter.register_unstructure_hook`,
{meth}`BaseConverter.register_unstructure_hook_factory` and \
{meth}`BaseConverter.register_structure_hook_factory`
can now be used as decorators and have gained new features.
See [here](https://catt.rs/en/latest/customizing.html#use-as-decorators) and \
[here](https://catt.rs/en/latest/customizing.html#id1) for more details.
- Introduce and \
[document](https://catt.rs/en/latest/customizing.html#customizing-collections) \
the {mod}`cattrs.cols` module for better collection customizations.
- Enhance the {func}`cattrs.cols.is_mapping` predicate function to also cover \
virtual subclasses of `abc.Mapping`.
This enables map classes from libraries such as _immutables_ or \
_sortedcontainers_ to structure out-of-the-box.
- Introduce the [_msgspec_](https://jcristharif.com/msgspec/) {mod}`preconf \
converter <cattrs.preconf.msgspec>`.
Only JSON is supported for now, with other formats supported by _msgspec_ to \
come later.
- The default union handler now properly takes renamed fields into account.
- The default union handler now also handles dataclasses.
- Add support for [PEP 695](https://peps.python.org/pep-0695/) type aliases.
- Add support for [PEP 696](https://peps.python.org/pep-0696/) `TypeVar`s with \
defaults.
- Add support for named tuples with type metadata \
([`typing.NamedTuple`](https://docs.python.org/3/library/typing.html#typing.NamedTuple)).
- Add support for optionally un/unstructuring named tuples using dictionaries.
- The `include_subclasses` strategy now fetches the member hooks from the \
converter (making use of converter defaults) if overrides are not provided, \
instead of generating new hooks with no overrides.
- The preconf `make_converter` factories are now correctly typed.
- The {class}`orjson preconf converter \
<cattrs.preconf.orjson.OrjsonConverter>` now passes through dates and \
datetimes to orjson while unstructuring, greatly improving speed.
- {mod}`cattrs.gen` generators now attach metadata to the generated functions, \
making them introspectable.
- Structure hook factories in {mod}`cattrs.gen` now handle recursive classes better.
- The [tagged union \
strategy](https://catt.rs/en/stable/strategies.html#tagged-unions-strategy) now \
leaves the tags in the payload unless `forbid_extra_keys` is set.
- More robust support for `Annotated` and `NotRequired` in TypedDicts.
- `typing_extensions.Literal` is now automatically structured, just like \
`typing.Literal`.
- `typing_extensions.Any` is now supported and handled like `typing.Any`.
- `Optional` types can now be consistently customized using \
`register_structure_hook` and `register_unstructure_hook`.
- The BaseConverter now properly generates detailed validation errors for mappings.
- [PEP 695](https://peps.python.org/pep-0695/) generics are now tested.
- Imports are now sorted using Ruff.
- Tests are run with the pytest-xdist plugin by default.
- Rework the introductory parts of the documentation, introducing the Basics section.
- The documentation has been significantly reworked.
- The docs now use the Inter font.
- Make type annotations for `include_subclasses` and `tagged_union` strategies \
more lenient.
Files: