cattrs の API リファレンス
cattrs (python-attrs/cattrs) の公開 API 63 件 —— クラス 7、関数 41、メソッド 15。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: python-attrs/cattrs
| 種別 | 件数 |
|---|---|
| クラス | 7 |
| 関数 | 41 |
| メソッド | 15 |
API 一覧
func
src.cattrs._compat.adapted_fields(cl:type) -> list[Attribute]Return the attrs format of `fields()` for attrs and dataclasses.
func
src.cattrs._compat.copy_with(type, args)Replace a generic type's arguments.
func
src.cattrs._compat.fields_dict(type) -> dict[str, Union[Attribute, Field]]Return the fields_dict for attrs and dataclasses.
func
src.cattrs._compat.is_frozenset(type:Any) -> boolA predicate function for frozensets.
func
src.cattrs._compat.is_generic(type) -> boolWhether `type` is a generic type.
func
src.cattrs._compat.is_literal(type:Any) -> boolIs this a literal?
func
src.cattrs._compat.is_mapping(type:Any) -> boolA predicate function for mappings.
func
src.cattrs._compat.is_mutable_sequence(type:Any) -> boolA predicate function for mutable sequences.
func
src.cattrs._compat.is_mutable_set(type:Any) -> boolA predicate function for (mutable) sets.
func
src.cattrs._compat.is_sequence(type:Any) -> boolA predicate function for sequences.
func
src.cattrs._compat.is_subclass(obj:type, bases) -> boolA safe version of issubclass (won't raise).
func
src.cattrs._compat.is_typeddict(cls:Any)Thin wrapper around typing(_extensions).is_typeddict
func
src.cattrs.cols.is_abstract_set(type) -> boolA predicate function for abstract (collection.abc) sets.
func
src.cattrs.cols.is_any_set(type) -> boolA predicate function for both mutable and frozensets.
func
src.cattrs.cols.is_defaultdict(type:Any) -> boolIs this type a defaultdict?
func
src.cattrs.cols.is_namedtuple(type:Any) -> boolA predicate function for named tuples.
func
src.cattrs.cols.list_structure_factory(type:type, converter:BaseConverter) -> StructureHookA hook factory for structuring lists.
func
src.cattrs.cols.namedtuple_unstructure_factory(cl:type[tuple], converter:BaseConverter, unstructure_to:Any=None) -> UnstructureHookA hook factory for unstructuring namedtuples.
class
src.cattrs.converters.BaseConverterConverts between structured and unstructured data.
method
src.cattrs.converters.BaseConverter.gen_structure_hetero_tuple(cl:Any) -> HeteroTupleStructureFnGenerate a heterogeneous tuple structure function.
method
src.cattrs.converters.BaseConverter.get_structure_hook(type:Any, cache_result:bool=True) -> StructureHookGet the structure hook for the given type.
method
src.cattrs.converters.BaseConverter.get_unstructure_hook(type:Any, cache_result:bool=True) -> UnstructureHookGet the unstructure hook for the given type.
method
src.cattrs.converters.BaseConverter.structure(obj:UnstructuredValue, cl:type[T]) -> TConvert unstructured Python data structures to structured data.
method
src.cattrs.converters.BaseConverter.structure_attrs_fromdict(obj:Mapping[str, Any], cl:type[T]) -> TInstantiate an attrs class from a mapping (dict).
method
src.cattrs.converters.BaseConverter.structure_attrs_fromtuple(obj:tuple[Any, ...], cl:type[T]) -> TLoad an attrs class from a sequence (tuple).
method
src.cattrs.converters.BaseConverter.unstructure_attrs_asdict(obj:Any) -> dict[str, Any]Our version of `attrs.asdict`, so we can call back to us.
method
src.cattrs.converters.Converter.gen_structure_annotated(type) -> CallableA hook factory for annotated types.
method
src.cattrs.converters.Converter.gen_structure_typeddict(cl:Any) -> Callable[[dict, Any], dict]Generate a TypedDict structure function.
method
src.cattrs.converters.Converter.gen_unstructure_optional(cl:type[T]) -> Callable[[T], Any]Generate an unstructuring hook for optional types.
method
src.cattrs.converters.Converter.gen_unstructure_typeddict(cl:Any) -> Callable[[dict], dict]Generate a TypedDict unstructure function.
class
src.cattrs.converters.UnstructureStrategy`attrs` classes unstructuring strategies.
func
src.cattrs.disambiguators.is_supported_union(typ:Any) -> boolWhether the type is a union of attrs classes or dataclasses.
func
src.cattrs.enums.enum_structure_factory(type:type[Enum], converter:'BaseConverter') -> Callable[[Any, type[Enum]], Enum]A factory for generating enum structure hooks.
func
src.cattrs.enums.enum_unstructure_factory(type:type[Enum], converter:'BaseConverter') -> Callable[[Enum], Any]A factory for generating enum unstructure hooks.
class
src.cattrs.errors.CattrsErrorBase ``cattrs`` exception.
class
src.cattrs.errors.IterableValidationErrorRaised when structuring an iterable.
func
src.cattrs.fns.identity(obj:T) -> TThe identity function.
func
src.cattrs.fns.raise_error(_, cl:Any) -> NoReturnAt the bottom of the condition stack, we explode if we can't handle it.
func
src.cattrs.gen._shared.find_structure_handler(a:Attribute, type:Any, c:BaseConverter, prefer_attrs_converters:bool=False) -> StructureHook | NoneFind the appropriate structure handler to use.
func
src.cattrs.gen.iterable_unstructure_factory(cl:Any, converter:BaseConverter, unstructure_to:Any=None) -> UnstructureHookA hook factory for unstructuring iterables.
func
src.cattrs.literals.is_literal_containing_enums(type:Any) -> boolIs this a literal containing at least one Enum?
class
src.cattrs.preconf.bson.Base85BytesA subclass to help with binary key encoding/decoding.
func
src.cattrs.preconf.is_primitive_enum(type:Any, include_bare_enums:bool=False) -> boolIs this a string or int enum that can be passed through?
func
src.cattrs.preconf.json.configure_converter(converter:BaseConverter) -> NoneConfigure the converter for use with the stdlib json module.
func
src.cattrs.preconf.msgpack.configure_converter(converter:BaseConverter) -> NoneConfigure the converter for use with the msgpack library.
class
src.cattrs.preconf.msgspec.MsgspecJsonConverterA converter specialized for the _msgspec_ library.
method
src.cattrs.preconf.msgspec.MsgspecJsonConverter.dumps(obj:Any, unstructure_as:Any=None, **kwargs:Any) -> bytesUnstructure and encode `obj` into JSON bytes.
method
src.cattrs.preconf.msgspec.MsgspecJsonConverter.get_dumps_hook(unstructure_as:Any, **kwargs:Any) -> Callable[[Any], bytes]Produce a `dumps` hook for the given type.
method
src.cattrs.preconf.msgspec.MsgspecJsonConverter.get_loads_hook(cl:type[T]) -> Callable[[bytes], T]Produce a `loads` hook for the given type.
method
src.cattrs.preconf.msgspec.MsgspecJsonConverter.loads(data:bytes, cl:type[T], **kwargs:Any) -> TDecode and structure `cl` from the provided JSON bytes.
func
src.cattrs.preconf.msgspec.configure_converter(converter:Converter) -> NoneConfigure the converter for the msgspec library.
func
src.cattrs.preconf.msgspec.configure_passthroughs(converter:Converter) -> NoneConfigure optimizing passthroughs.
func
src.cattrs.preconf.msgspec.mapping_unstructure_factory(type, converter:Converter) -> UnstructureHookThe msgspec unstructure hook factory for mappings.
func
src.cattrs.preconf.msgspec.seq_unstructure_factory(type, converter:Converter) -> UnstructureHookThe msgspec unstructure hook factory for sequences.
func
src.cattrs.preconf.orjson.configure_converter(converter:Converter) -> NoneConfigure the converter for use with the orjson library.
func
src.cattrs.preconf.pyyaml.configure_converter(converter:BaseConverter) -> NoneConfigure the converter for use with the pyyaml library.
class
src.cattrs.preconf.tomllib.TomllibConverterA converter subclass specialized for tomllib.
func
src.cattrs.preconf.wrap(_:Callable[P, Any]) -> Callable[[Callable[..., T]], Callable[P, T]]Wrap a `Converter` `__init__` in a type-safe way.
func
src.cattrs.strategies._unions.contains_native_union(exact_type:Any) -> boolCan we handle this type?
func
src.cattrs.strategies._unions.default_tag_generator(typ:type) -> strReturn the class name.
func
src.cattrs.subclasses.subclasses(cls:type) -> list[type]A proxy for `cls.__subclasses__()` on older Pythons.
func
src.cattrs.typealiases.get_type_alias_base(type:Any) -> AnyWhat is this a type alias of?
func
src.cattrs.typealiases.is_type_alias(type:Any) -> boolIs this a PEP 695 type alias?
この情報について
掲載しているシグネチャは python-attrs/cattrs の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。