API reference
tinyconfig
BaseConfig
dataclass
to_dict
to_dict() -> dict[str, Any]
Convert the dataclass instance to a dictionary.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, Any]
|
A dictionary representation of the dataclass instance. |
from_dict
classmethod
from_dict(data: dict[str, Any]) -> T
Create a dataclass instance from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
A dictionary containing the data to populate the dataclass. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseConfig |
T
|
An instance of the dataclass. |
to_toml
to_toml() -> str
Convert the dataclass instance to a TOML string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A TOML string representation of the dataclass instance. |
from_toml
classmethod
from_toml(toml_str: str) -> T
Create a dataclass instance from a TOML string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
toml_str
|
str
|
A TOML string containing the data to populate the dataclass. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseConfig |
T
|
An instance of the dataclass. |
to_json
to_json() -> str
Convert the dataclass instance to a JSON string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A JSON string representation of the dataclass instance. |
from_json
classmethod
from_json(json_str: str) -> T
Create a dataclass instance from a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_str
|
str
|
A JSON string containing the data to populate the dataclass. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseConfig |
T
|
An instance of the dataclass. |
to_yaml
to_yaml() -> str
Convert the dataclass instance to a YAML string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A YAML string representation of the dataclass instance. |
from_yaml
classmethod
from_yaml(yaml_str: str) -> T
Create a dataclass instance from a YAML string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yaml_str
|
str
|
A YAML string containing the data to populate the dataclass. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseConfig |
T
|
An instance of the dataclass. |
base
BaseConfig
dataclass
to_dict
to_dict() -> dict[str, Any]
Convert the dataclass instance to a dictionary.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, Any]
|
A dictionary representation of the dataclass instance. |
from_dict
classmethod
from_dict(data: dict[str, Any]) -> T
Create a dataclass instance from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
A dictionary containing the data to populate the dataclass. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseConfig |
T
|
An instance of the dataclass. |
to_toml
to_toml() -> str
Convert the dataclass instance to a TOML string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A TOML string representation of the dataclass instance. |
from_toml
classmethod
from_toml(toml_str: str) -> T
Create a dataclass instance from a TOML string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
toml_str
|
str
|
A TOML string containing the data to populate the dataclass. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseConfig |
T
|
An instance of the dataclass. |
to_json
to_json() -> str
Convert the dataclass instance to a JSON string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A JSON string representation of the dataclass instance. |
from_json
classmethod
from_json(json_str: str) -> T
Create a dataclass instance from a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_str
|
str
|
A JSON string containing the data to populate the dataclass. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseConfig |
T
|
An instance of the dataclass. |
to_yaml
to_yaml() -> str
Convert the dataclass instance to a YAML string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A YAML string representation of the dataclass instance. |
from_yaml
classmethod
from_yaml(yaml_str: str) -> T
Create a dataclass instance from a YAML string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yaml_str
|
str
|
A YAML string containing the data to populate the dataclass. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseConfig |
T
|
An instance of the dataclass. |