cattrs
cattrs copied to clipboard
Composable custom class converters for attrs, dataclasses and friends.
For a thing at work, I implemented some [un]structure hook factories that wrap `make_dict_structure_fn` and `make_dict_unstructure_fn` to support flattening an attribute, like this: ```python @define class A: a: int b:...
* cattrs version: 23.1.0.dev0 * Python version: 3.11.1 * Operating System: Manjaro KDE ### Description Subsets of tagged unions should also be able to use the configured strategy. ### What...
* cattrs version: 23.1.0.dev0 * Python version: 3.11.1 * Operating System: Manjaro KDE ### Description An optional tagged union doesn't work. I believe the `Optional` (or `| None`) portion could...
* cattrs version: 22.2.0 * Python version: 3.9 * Operating System: Ubuntu 20.04 ### Description When you wrap a union type multiple times, e.g., `Optional[list[Union[A, B]]]`, the custom unstructure function...
* cattrs version: 22.2.0 * Python version: 3.11 * Operating System: Windows 10 ### Description I have a @frozen class that inherits a @frozen class containing two enums PType and...
* cattrs version: 22.2.0 * Python version: 3.9 * Operating System: macOS / Linux ### Description There is a regression in unstructuring of statically typed `Any` field in versions published...
* cattrs version: 22.2.0 * Python version: 3.9.13 * Operating System: Ubuntu 20.04.1 ### Description I was glad to see https://github.com/python-attrs/cattrs/pull/231 which fixes the structuring of `enum.Enum` instances in `typing.Literal`...
(I know it's not a cattrs issue.) I'm looking for a way to JSON-serialize a type-ref inside a attrs-class. But type-refs aren't supported by json-lib. See a litte example: ```...
When implementing PEP 696 (default values for TypeVars, ParamSpecs and TypeVarTuples, we decided to implement the PEP slightly differently from the prototype that existed in `typing_extensions`. Specifically: - With the...
* cattrs version: 23.2.3 * Python version: 3.10.12 * Operating System: Ubuntu-22.04 I'm using attrs 23.2.0, if that matters. ### Description Hi! I am having trouble adding the special `_type`...