sdkagent

cattrs API reference

63 public APIs from cattrs (python-attrs/cattrs) — 7 classes, 41 functions, 15 methods. Signatures extracted by static analysis of the actual source.

Repository: python-attrs/cattrs

KindCount
Classes7
Functions41
Methods15

API list

funcsrc.cattrs._compat.adapted_fields(cl:type) -> list[Attribute]
Return the attrs format of `fields()` for attrs and dataclasses.
funcsrc.cattrs._compat.copy_with(type, args)
Replace a generic type's arguments.
funcsrc.cattrs._compat.fields_dict(type) -> dict[str, Union[Attribute, Field]]
Return the fields_dict for attrs and dataclasses.
funcsrc.cattrs._compat.is_frozenset(type:Any) -> bool
A predicate function for frozensets.
funcsrc.cattrs._compat.is_generic(type) -> bool
Whether `type` is a generic type.
funcsrc.cattrs._compat.is_literal(type:Any) -> bool
Is this a literal?
funcsrc.cattrs._compat.is_mapping(type:Any) -> bool
A predicate function for mappings.
funcsrc.cattrs._compat.is_mutable_sequence(type:Any) -> bool
A predicate function for mutable sequences.
funcsrc.cattrs._compat.is_mutable_set(type:Any) -> bool
A predicate function for (mutable) sets.
funcsrc.cattrs._compat.is_sequence(type:Any) -> bool
A predicate function for sequences.
funcsrc.cattrs._compat.is_subclass(obj:type, bases) -> bool
A safe version of issubclass (won't raise).
funcsrc.cattrs._compat.is_typeddict(cls:Any)
Thin wrapper around typing(_extensions).is_typeddict
funcsrc.cattrs.cols.is_abstract_set(type) -> bool
A predicate function for abstract (collection.abc) sets.
funcsrc.cattrs.cols.is_any_set(type) -> bool
A predicate function for both mutable and frozensets.
funcsrc.cattrs.cols.is_defaultdict(type:Any) -> bool
Is this type a defaultdict?
funcsrc.cattrs.cols.is_namedtuple(type:Any) -> bool
A predicate function for named tuples.
funcsrc.cattrs.cols.list_structure_factory(type:type, converter:BaseConverter) -> StructureHook
A hook factory for structuring lists.
funcsrc.cattrs.cols.namedtuple_unstructure_factory(cl:type[tuple], converter:BaseConverter, unstructure_to:Any=None) -> UnstructureHook
A hook factory for unstructuring namedtuples.
classsrc.cattrs.converters.BaseConverter
Converts between structured and unstructured data.
methodsrc.cattrs.converters.BaseConverter.gen_structure_hetero_tuple(cl:Any) -> HeteroTupleStructureFn
Generate a heterogeneous tuple structure function.
methodsrc.cattrs.converters.BaseConverter.get_structure_hook(type:Any, cache_result:bool=True) -> StructureHook
Get the structure hook for the given type.
methodsrc.cattrs.converters.BaseConverter.get_unstructure_hook(type:Any, cache_result:bool=True) -> UnstructureHook
Get the unstructure hook for the given type.
methodsrc.cattrs.converters.BaseConverter.structure(obj:UnstructuredValue, cl:type[T]) -> T
Convert unstructured Python data structures to structured data.
methodsrc.cattrs.converters.BaseConverter.structure_attrs_fromdict(obj:Mapping[str, Any], cl:type[T]) -> T
Instantiate an attrs class from a mapping (dict).
methodsrc.cattrs.converters.BaseConverter.structure_attrs_fromtuple(obj:tuple[Any, ...], cl:type[T]) -> T
Load an attrs class from a sequence (tuple).
methodsrc.cattrs.converters.BaseConverter.unstructure_attrs_asdict(obj:Any) -> dict[str, Any]
Our version of `attrs.asdict`, so we can call back to us.
methodsrc.cattrs.converters.Converter.gen_structure_annotated(type) -> Callable
A hook factory for annotated types.
methodsrc.cattrs.converters.Converter.gen_structure_typeddict(cl:Any) -> Callable[[dict, Any], dict]
Generate a TypedDict structure function.
methodsrc.cattrs.converters.Converter.gen_unstructure_optional(cl:type[T]) -> Callable[[T], Any]
Generate an unstructuring hook for optional types.
methodsrc.cattrs.converters.Converter.gen_unstructure_typeddict(cl:Any) -> Callable[[dict], dict]
Generate a TypedDict unstructure function.
classsrc.cattrs.converters.UnstructureStrategy
`attrs` classes unstructuring strategies.
funcsrc.cattrs.disambiguators.is_supported_union(typ:Any) -> bool
Whether the type is a union of attrs classes or dataclasses.
funcsrc.cattrs.enums.enum_structure_factory(type:type[Enum], converter:'BaseConverter') -> Callable[[Any, type[Enum]], Enum]
A factory for generating enum structure hooks.
funcsrc.cattrs.enums.enum_unstructure_factory(type:type[Enum], converter:'BaseConverter') -> Callable[[Enum], Any]
A factory for generating enum unstructure hooks.
classsrc.cattrs.errors.CattrsError
Base ``cattrs`` exception.
classsrc.cattrs.errors.IterableValidationError
Raised when structuring an iterable.
funcsrc.cattrs.fns.identity(obj:T) -> T
The identity function.
funcsrc.cattrs.fns.raise_error(_, cl:Any) -> NoReturn
At the bottom of the condition stack, we explode if we can't handle it.
funcsrc.cattrs.gen._shared.find_structure_handler(a:Attribute, type:Any, c:BaseConverter, prefer_attrs_converters:bool=False) -> StructureHook | None
Find the appropriate structure handler to use.
funcsrc.cattrs.gen.iterable_unstructure_factory(cl:Any, converter:BaseConverter, unstructure_to:Any=None) -> UnstructureHook
A hook factory for unstructuring iterables.
funcsrc.cattrs.literals.is_literal_containing_enums(type:Any) -> bool
Is this a literal containing at least one Enum?
classsrc.cattrs.preconf.bson.Base85Bytes
A subclass to help with binary key encoding/decoding.
funcsrc.cattrs.preconf.is_primitive_enum(type:Any, include_bare_enums:bool=False) -> bool
Is this a string or int enum that can be passed through?
funcsrc.cattrs.preconf.json.configure_converter(converter:BaseConverter) -> None
Configure the converter for use with the stdlib json module.
funcsrc.cattrs.preconf.msgpack.configure_converter(converter:BaseConverter) -> None
Configure the converter for use with the msgpack library.
classsrc.cattrs.preconf.msgspec.MsgspecJsonConverter
A converter specialized for the _msgspec_ library.
methodsrc.cattrs.preconf.msgspec.MsgspecJsonConverter.dumps(obj:Any, unstructure_as:Any=None, **kwargs:Any) -> bytes
Unstructure and encode `obj` into JSON bytes.
methodsrc.cattrs.preconf.msgspec.MsgspecJsonConverter.get_dumps_hook(unstructure_as:Any, **kwargs:Any) -> Callable[[Any], bytes]
Produce a `dumps` hook for the given type.
methodsrc.cattrs.preconf.msgspec.MsgspecJsonConverter.get_loads_hook(cl:type[T]) -> Callable[[bytes], T]
Produce a `loads` hook for the given type.
methodsrc.cattrs.preconf.msgspec.MsgspecJsonConverter.loads(data:bytes, cl:type[T], **kwargs:Any) -> T
Decode and structure `cl` from the provided JSON bytes.
funcsrc.cattrs.preconf.msgspec.configure_converter(converter:Converter) -> None
Configure the converter for the msgspec library.
funcsrc.cattrs.preconf.msgspec.configure_passthroughs(converter:Converter) -> None
Configure optimizing passthroughs.
funcsrc.cattrs.preconf.msgspec.mapping_unstructure_factory(type, converter:Converter) -> UnstructureHook
The msgspec unstructure hook factory for mappings.
funcsrc.cattrs.preconf.msgspec.seq_unstructure_factory(type, converter:Converter) -> UnstructureHook
The msgspec unstructure hook factory for sequences.
funcsrc.cattrs.preconf.orjson.configure_converter(converter:Converter) -> None
Configure the converter for use with the orjson library.
funcsrc.cattrs.preconf.pyyaml.configure_converter(converter:BaseConverter) -> None
Configure the converter for use with the pyyaml library.
classsrc.cattrs.preconf.tomllib.TomllibConverter
A converter subclass specialized for tomllib.
funcsrc.cattrs.preconf.wrap(_:Callable[P, Any]) -> Callable[[Callable[..., T]], Callable[P, T]]
Wrap a `Converter` `__init__` in a type-safe way.
funcsrc.cattrs.strategies._unions.contains_native_union(exact_type:Any) -> bool
Can we handle this type?
funcsrc.cattrs.strategies._unions.default_tag_generator(typ:type) -> str
Return the class name.
funcsrc.cattrs.subclasses.subclasses(cls:type) -> list[type]
A proxy for `cls.__subclasses__()` on older Pythons.
funcsrc.cattrs.typealiases.get_type_alias_base(type:Any) -> Any
What is this a type alias of?
funcsrc.cattrs.typealiases.is_type_alias(type:Any) -> bool
Is this a PEP 695 type alias?

About this data

These signatures were extracted from the public source of python-attrs/cattrs using Python's ast module. Argument names, default values, type annotations and return types are taken verbatim from the code. Implementation bodies are never stored. See how it works for details.

Back to all 805 libraries