Path to this page:
./
devel/py-cattrs,
Composable complex class support for attrs and dataclasses
Branch: CURRENT,
Version: 24.1.2,
Package name: py312-cattrs-24.1.2,
Maintainer: pkgsrc-userscattrs is an open source Python library for structuring and
unstructuring data. cattrs works best with attrs classes, dataclasses
and the usual Python collections, but other kinds of classes are
supported by manually registering converters.
Python has a rich set of powerful, easy to use, built-in data types
like dictionaries, lists and tuples. These data types are also the
lingua franca of most data serialization libraries, for formats
like json, msgpack, yaml or toml.
Data types like this, and mappings like dict s in particular,
represent unstructured data. Your data is, in all likelihood,
structured: not all combinations of field names or values are valid
inputs to your programs. In Python, structured data is better
represented with classes and enumerations. attrs is an excellent
library for declaratively describing the structure of your data,
and validating it.
When you're handed unstructured data (by your network, file system,
database...), cattrs helps to convert this data into structured data.
When you have to convert your structured data into data types other
libraries can handle, cattrs turns your classes and enumerations
into dictionaries, integers and strings.
Master sites:
Filesize: 416.467 KB
Version history: (Expand)
- (2024-09-23) Updated to version: py312-cattrs-24.1.2
- (2024-09-12) Updated to version: py312-cattrs-24.1.1
- (2024-08-30) Updated to version: py312-cattrs-24.1.0
- (2023-12-01) Updated to version: py311-cattrs-23.2.3
- (2023-11-22) Updated to version: py311-cattrs-23.2.2
- (2023-11-19) Updated to version: py311-cattrs-23.2.1
CVS history: (Expand)
2024-09-23 10:10:07 by Adam Ciarcinski | Files touched by this commit (2) | |
Log message:
py-cattrs: updated to 24.1.2
24.1.2 (2024-09-22)
- Fix {meth}`BaseConverter.register_structure_hook` and \
{meth}`BaseConverter.register_unstructure_hook` type hints.
|
2024-09-12 21:45:33 by Adam Ciarcinski | Files touched by this commit (2) | |
Log message:
py-cattrs: updated to 24.1.1
24.1.1 (2024-09-11)
- Fix {meth}`BaseConverter.register_structure_hook_factory` and \
{meth}`BaseConverter.register_unstructure_hook_factory` type hints.
|
2024-08-30 09:18:12 by Adam Ciarcinski | Files touched by this commit (3) | |
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.
|
2023-12-01 13:58:12 by Adam Ciarcinski | Files touched by this commit (2) | |
Log message:
py-cattrs: updated to 23.2.3
23.2.3 (2023-11-30)
- Fix a regression when unstructuring dictionary values typed as `Any`.
- Fix a regression when unstructuring unspecialized generic classes.
- Optimize function source code caching.
- Generate unique files only in case of linecache enabled.
|
2023-11-22 12:43:01 by Adam Ciarcinski | Files touched by this commit (2) | |
Log message:
py-cattrs: updated to 23.2.2
23.2.2 (2023-11-21)
- Fix a regression when unstructuring `Any | None`.
|
2023-11-19 15:09:31 by Thomas Klausner | Files touched by this commit (3) | |
Log message:
py-cattrs: update to 23.2.1.
## 23.2.1 (2023-11-18)
- Fix unnecessary `typing_extensions` import on Python 3.11.
## 23.2.0 (2023-11-17)
- **Potentially breaking**: skip _attrs_ fields marked as `init=False` by \
default. This change is potentially breaking for unstructuring.
- **Potentially breaking**: {py:func}`cattrs.gen.make_dict_structure_fn` and \
{py:func}`cattrs.gen.typeddicts.make_dict_structure_fn` will use the values for \
the `detailed_validation` and `forbid_extra_keys` parameters from the given \
converter by default now.
If you're using these functions directly, the old behavior can be restored by \
passing in the desired values directly.
- **Potentially breaking**: The default union structuring strategy will also use \
fields annotated as `typing.Literal` to help guide structuring.
- Python 3.12 is now supported. Python 3.7 is no longer supported; use older \
releases there.
- Implement the `union passthrough` strategy, enabling much richer union \
handling for preconfigured converters.
- Introduce the `use_class_methods` strategy.
- The `omit` parameter of {py:func}`cattrs.override` is now of type `bool | \
None` (from `bool`).
`None` is the new default and means to apply default _cattrs_ handling to the \
attribute, which is to omit the attribute if it's marked as `init=False`, and \
keep it otherwise.
- Converters can now be initialized with custom fallback hook factories for \
un/structuring.
- Add support for `date` to preconfigured converters.
- Add support for `datetime.date`s to the PyYAML preconfigured converter.
- Fix {py:func}`format_exception() <cattrs.v.format_exception>` parameter \
working for recursive calls to {py:func}`transform_error \
<cattrs.transform_error>`.
- _attrs_ aliases are now supported, although aliased fields still map to their \
attribute name instead of their alias by default when un/structuring.
- Fix TypedDicts with periods in their field names.
- Optimize and improve unstructuring of `Optional` (unions of one type and `None`).
- Fix {py:func}`format_exception <cattrs.v.format_exception>` and \
{py:func}`transform_error <cattrs.transform_error>` type annotations.
- Improve the implementation of `cattrs._compat.is_typeddict`. The \
implementation is now simpler, and relies on fewer private implementation \
details from `typing` and typing_extensions.
- Improve handling of TypedDicts with forward references.
- Speed up generated _attrs_ and TypedDict structuring functions by changing \
their signature slightly.
- Fix copying of converters with function hooks.
- Broaden {py:func}`loads' <cattrs.preconf.orjson.OrjsonConverter.loads>` \
type definition for the preconf orjson converter.
- {py:class}`AttributeValidationNote <cattrs.AttributeValidationNote>` and \
{py:class}`IterableValidationNote <cattrs.IterableValidationNote>` are now \
picklable.
- Fix structuring `Final` lists.
- Fix certain cases of structuring `Annotated` types.
- Fix the tagged union strategy to work with `forbid_extra_keys`.
- Use PDM instead of Poetry.
- _cattrs_ is now linted with Ruff.
- Remove some unused lines in the unstructuring code.
- Fix handling classes inheriting from non-generic protocols.
- The documentation Makefile now supports the `htmlview` and `htmllive` targets.
- _cattrs_ is now published using PyPI Trusted Publishers, and `main` branch \
commits are automatically deployed to Test PyPI.
|
2023-10-28 21:57:26 by Thomas Klausner | Files touched by this commit (516) | |
Log message:
python/wheel.mk: simplify a lot, and switch to 'installer' for installation
This follows the recommended bootstrap method (flit_core, build, installer).
However, installer installs different files than pip, so update PLISTs
for all packages using wheel.mk and bump their PKGREVISIONs.
|
2023-06-06 10:09:47 by Thomas Klausner | Files touched by this commit (3) | |
Log message:
py-cattrs: update to 23.1.2.
23.1.2 (2023-06-02)
Improve typing_extensions version bound. (#372)
23.1.1 (2023-05-30)
Add typing_extensions as a direct dependency on 3.10. (#369 #370)
23.1.0 (2023-05-30)
Introduce the tagged_union strategy. (#318 #317)
Introduce the cattrs.transform_error helper function for formatting \
validation exceptions. (258 342)
Add support for typing.TypedDict and typing_extensions.TypedDict. (#296 #364)
Add support for typing.Final. (#340 #349)
Introduce override.struct_hook and override.unstruct_hook. Learn more here. \
(#326)
Fix generating structuring functions for types with angle brackets \
(<>) and pipe symbols (|) in the name. (#319 #327)
pathlib.Path is now supported by default. (#81)
Add cbor2 serialization library to the cattr.preconf package.
Add optional dependencies for cattrs.preconf third-party libraries. (#337)
All preconf converters now allow overriding the default \
unstruct_collection_overrides in make_converter. (#350 #353)
Subclasses structuring and unstructuring is now supported via a custom \
include_subclasses strategy. (#312)
Add support for typing_extensions.Annotated when the python version is less \
than 3.9. (#366)
Add unstructuring and structuring support for the standard library deque. (#355)
|