Name | confdantic JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | Generate user-friendly configuration files from Pydantic models |
upload_time | 2025-07-18 18:49:09 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT License
Copyright (c) 2024 zigai
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
confdantic
config
pydantic
pydantic-config
pydantic-config-file
pydantic-configuration
pydantic-toml-comments
pydantic-yaml-comments
toml
toml-configuration
yaml
yaml-configuration
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# confdantic
[](https://github.com/zigai/confdantic/actions/workflows/tests.yml)
[](https://badge.fury.io/py/confdantic)

[](https://pepy.tech/project/confdantic)
[](https://github.com/zigai/confdantic/blob/master/LICENSE)
`Confdantic` is a Python library that enhances Pydantic's capabilities for working with JSON, YAML, and TOML formats by preserving field descriptions as comments when serializing to YAML or TOML.
## Installation
### Using pip
```sh
pip install confdantic
```
### Using uv
```sh
uv add confdantic
```
### From source
```sh
pip install git+https://github.com/zigai/confdantic.git
# or
uv add git+https://github.com/zigai/confdantic.git
```
## Example
```python
from typing import Literal
from pydantic import Field
from confdantic import Confdantic
class DatabaseConfig(Confdantic):
host: str = Field(
"localhost",
description="The hostname or IP address of the database server",
)
port: int = Field(
5432,
description="The port number on which the database server is listening.",
)
username: str
password: str
class ApplicationConfig(Confdantic):
debug: bool = Field(False, description="Enable debug mode")
log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR"] = Field(
"INFO", description="Logging level"
)
database: DatabaseConfig
allowed_hosts: list[str] = Field(
default_factory=list,
description="A list of host/domain names that this application can serve.",
)
config = ApplicationConfig(
database=DatabaseConfig(username="admin", password="secret"),
allowed_hosts=["example.com"],
)
config.save("config.yaml", comments=True)
config.save("config.toml", comments=True)
```
`config.yaml`
```yaml
debug: false # Enable debug mode
log_level: INFO # Logging level | choices: DEBUG, INFO, WARNING, ERROR
database:
host: localhost # The hostname or IP address of the database server
port: 5432 # The port number on which the database server is listening.
username: admin
password: secret
allowed_hosts: # A list of host/domain names that this application can serve.
- example.com
```
`config.toml`
```toml
debug = false # Enable debug mode
log_level = "INFO" # Logging level | choices: DEBUG, INFO, WARNING, ERROR
allowed_hosts = ["example.com"] # A list of host/domain names that this application can serve.
[database]
host = "localhost" # The hostname or IP address of the database server
port = 5432 # The port number on which the database server is listening.
username = "admin"
password = "secret"
```
## License
[MIT License](https://github.com/zigai/confdantic/blob/master/LICENSE)
Raw data
{
"_id": null,
"home_page": null,
"name": "confdantic",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "confdantic, config, pydantic, pydantic-config, pydantic-config-file, pydantic-configuration, pydantic-toml-comments, pydantic-yaml-comments, toml, toml-configuration, yaml, yaml-configuration",
"author": null,
"author_email": "zigai <ziga.ivansek@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/bd/d1/0ba37b683dc49b59bad08c2238d6289750e8cba577d55ef102c7747ecbdf/confdantic-0.1.0.tar.gz",
"platform": null,
"description": "# confdantic\n\n[](https://github.com/zigai/confdantic/actions/workflows/tests.yml)\n[](https://badge.fury.io/py/confdantic)\n\n[](https://pepy.tech/project/confdantic)\n[](https://github.com/zigai/confdantic/blob/master/LICENSE)\n\n`Confdantic` is a Python library that enhances Pydantic's capabilities for working with JSON, YAML, and TOML formats by preserving field descriptions as comments when serializing to YAML or TOML.\n\n## Installation\n\n### Using pip\n\n```sh\npip install confdantic\n```\n\n### Using uv\n\n```sh\nuv add confdantic\n```\n\n### From source\n\n```sh\npip install git+https://github.com/zigai/confdantic.git\n# or\nuv add git+https://github.com/zigai/confdantic.git\n```\n\n## Example\n\n```python\nfrom typing import Literal\nfrom pydantic import Field\nfrom confdantic import Confdantic\n\nclass DatabaseConfig(Confdantic):\n host: str = Field(\n \"localhost\",\n description=\"The hostname or IP address of the database server\",\n )\n port: int = Field(\n 5432,\n description=\"The port number on which the database server is listening.\",\n )\n username: str\n password: str\n\nclass ApplicationConfig(Confdantic):\n debug: bool = Field(False, description=\"Enable debug mode\")\n log_level: Literal[\"DEBUG\", \"INFO\", \"WARNING\", \"ERROR\"] = Field(\n \"INFO\", description=\"Logging level\"\n )\n database: DatabaseConfig\n allowed_hosts: list[str] = Field(\n default_factory=list,\n description=\"A list of host/domain names that this application can serve.\",\n )\n\nconfig = ApplicationConfig(\n database=DatabaseConfig(username=\"admin\", password=\"secret\"),\n allowed_hosts=[\"example.com\"],\n)\nconfig.save(\"config.yaml\", comments=True)\nconfig.save(\"config.toml\", comments=True)\n```\n\n`config.yaml`\n\n```yaml\ndebug: false # Enable debug mode\nlog_level: INFO # Logging level | choices: DEBUG, INFO, WARNING, ERROR\ndatabase:\n host: localhost # The hostname or IP address of the database server\n port: 5432 # The port number on which the database server is listening.\n username: admin\n password: secret\nallowed_hosts: # A list of host/domain names that this application can serve.\n - example.com\n```\n\n`config.toml`\n\n```toml\ndebug = false # Enable debug mode\nlog_level = \"INFO\" # Logging level | choices: DEBUG, INFO, WARNING, ERROR\nallowed_hosts = [\"example.com\"] # A list of host/domain names that this application can serve.\n\n[database]\nhost = \"localhost\" # The hostname or IP address of the database server\nport = 5432 # The port number on which the database server is listening.\nusername = \"admin\"\npassword = \"secret\"\n```\n\n## License\n\n[MIT License](https://github.com/zigai/confdantic/blob/master/LICENSE)\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2024 zigai\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "Generate user-friendly configuration files from Pydantic models",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/zigai/confdantic",
"Issues": "https://github.com/zigai/confdantic/issues",
"Repository": "https://github.com/zigai/confdantic"
},
"split_keywords": [
"confdantic",
" config",
" pydantic",
" pydantic-config",
" pydantic-config-file",
" pydantic-configuration",
" pydantic-toml-comments",
" pydantic-yaml-comments",
" toml",
" toml-configuration",
" yaml",
" yaml-configuration"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "69e0e9ef98845c92d98a7f6817c282a790c7236571d7e3339d041524191a1b23",
"md5": "9c0193b6f75da3054ae44e83c76ace7a",
"sha256": "922ea66d54cce3ffadf910e48ba0cf0b03d51e90cb651cec7fdbc8c55db1de28"
},
"downloads": -1,
"filename": "confdantic-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9c0193b6f75da3054ae44e83c76ace7a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 6232,
"upload_time": "2025-07-18T18:49:08",
"upload_time_iso_8601": "2025-07-18T18:49:08.710358Z",
"url": "https://files.pythonhosted.org/packages/69/e0/e9ef98845c92d98a7f6817c282a790c7236571d7e3339d041524191a1b23/confdantic-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bdd10ba37b683dc49b59bad08c2238d6289750e8cba577d55ef102c7747ecbdf",
"md5": "0355cb3f95f39e77ed10f361e0ee095b",
"sha256": "80fd494314f7ca807c15d8211f6bdd9196bb8c61f694470a0cdd5ecfc438231c"
},
"downloads": -1,
"filename": "confdantic-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "0355cb3f95f39e77ed10f361e0ee095b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 38329,
"upload_time": "2025-07-18T18:49:09",
"upload_time_iso_8601": "2025-07-18T18:49:09.623110Z",
"url": "https://files.pythonhosted.org/packages/bd/d1/0ba37b683dc49b59bad08c2238d6289750e8cba577d55ef102c7747ecbdf/confdantic-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-18 18:49:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zigai",
"github_project": "confdantic",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "confdantic"
}