{"id":15436324,"url":"https://github.com/zigai/confdantic","last_synced_at":"2025-04-19T18:24:18.948Z","repository":{"id":249531687,"uuid":"741140617","full_name":"zigai/confdantic","owner":"zigai","description":"Generate user-friendly configuration files from Pydantic models","archived":false,"fork":false,"pushed_at":"2025-02-14T12:10:48.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T03:35:54.264Z","etag":null,"topics":["config","configuration-management","pydantic","pydantic-configuration","toml","toml-configuration","yaml","yaml-configuration"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zigai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-09T19:28:06.000Z","updated_at":"2025-02-14T11:46:45.000Z","dependencies_parsed_at":"2024-10-20T15:49:28.804Z","dependency_job_id":null,"html_url":"https://github.com/zigai/confdantic","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":0.09999999999999998,"last_synced_commit":"6e80e18f4e76078cadb093e600a6aad26bc14004"},"previous_names":["zigai/confdantic"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigai%2Fconfdantic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigai%2Fconfdantic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigai%2Fconfdantic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigai%2Fconfdantic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zigai","download_url":"https://codeload.github.com/zigai/confdantic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249762296,"owners_count":21321905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","configuration-management","pydantic","pydantic-configuration","toml","toml-configuration","yaml","yaml-configuration"],"created_at":"2024-10-01T18:49:55.385Z","updated_at":"2025-04-19T18:24:18.928Z","avatar_url":"https://github.com/zigai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Confdantic\n[![Tests](https://github.com/zigai/confdantic/actions/workflows/tests.yml/badge.svg)](https://github.com/zigai/confdantic/actions/workflows/tests.yml)\n[![PyPI version](https://badge.fury.io/py/confdantic.svg)](https://badge.fury.io/py/confdantic)\n![Supported versions](https://img.shields.io/badge/python-3.10+-blue.svg)\n[![Downloads](https://static.pepy.tech/badge/confdantic)](https://pepy.tech/project/confdantic)\n[![license](https://img.shields.io/github/license/zigai/confdantic.svg)](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.\nIt preserves field descriptions as comments when serializing to YAML or TOML, making it great for generating user-friendly configuration files.\n\n## Installation\n#### From PyPi\n```\npip install confdantic\n```\n#### From source\n```\npip install git+https://github.com/zigai/confdantic.git\n```\n## Example\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`config.yaml`\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`config.toml`\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## License\n[MIT License](https://github.com/zigai/confdantic/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigai%2Fconfdantic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzigai%2Fconfdantic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigai%2Fconfdantic/lists"}