yaml_dumpers
Class info¶
🛈 DocStrings¶
YAML dump functionality.
dump_yaml
¶
dump_yaml(
obj: Any,
class_mappings: dict[type, type] | None = None,
indent: int | None = None,
default_flow_style: bool | None = None,
allow_unicode: bool | None = None,
**kwargs: Any,
) -> str
Dump a data structure to a YAML string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
Object to serialize (also accepts pydantic models) |
required |
class_mappings
|
dict[type, type] | None
|
Dict mapping classes to built-in types for YAML representation |
None
|
indent
|
int | None
|
Indentation level for YAML output |
None
|
default_flow_style
|
bool | None
|
Whether to use flow style for YAML output |
None
|
allow_unicode
|
bool | None
|
Whether to allow unicode characters in YAML output |
None
|
kwargs
|
Any
|
Additional arguments for yaml.dump |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
YAML string representation |
Source code in src/configz/yaml_tools/yaml_dumpers.py
map_class_to_builtin_type
¶
Maps a Python class to use an existing PyYAML representer for a built-in type.
The original type is preserved, only the representation format is borrowed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dumper_class
|
DumperType
|
The YAML Dumper class |
required |
class_type
|
type
|
The custom Python class to map |
required |
target_type
|
type
|
The built-in type whose representer should be used |
required |