Skip to main content

A textual editor and validator for YAML/JSON files against Pydantic models.

Project description

Confantic

Confantic is a lightweight, text-based user interface to edit YAML and JSON configuration files with real-time validation and feedback.

YAML and JSON configuration files are all over the place. For less polished workflows, they can become a sort of "user interface" into the configuration of system. Expecting users to fill out text files to modify configuration is an extremely easy thing to develop, but has obvious UX limitations; the most notable of which is user's often don't know which fields are expected and their constraints. Confantic seeks to address this and take configuration files as UI a little more seriously.

Installation

pip install confantic

Usage

Confantic is built on top of Pydantic to define the configuration model. To use it, you first need a pydantic model to validate against. Lets use this one as an example:

model.py

from pydantic import BaseModel


class ProgramConfig(BaseModel):
    name: str
    version: str
    debug: bool = False

To specify which model to use when editing, you use a Model URI that tells python how to import the model. It supports two different specifications:

  1. <file path>:<model class> (ex. ./my_folder/my_file.py:MyModel)
  2. <module path>:<model class> (ex. my_module.my_submodule:MyModel)

Now, we can run the following command to start creating a config:

confantic model.py:ProgramConfig config.json

image

If the target file (config.json in this case) does not exist, it will populate the editor with some attempted defaults for the field - to at least give you the structure of the model. If we change some of the fields to create an error, we see the error show up at the bottom:

image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

confantic-1.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

confantic-1.0.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file confantic-1.0.0.tar.gz.

File metadata

  • Download URL: confantic-1.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for confantic-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c267212e49eeed140e79f3a36445d9d08d71114169a03f47e758032e9f636f6f
MD5 4475c90ffc1c7a216a0a22fb6aafce44
BLAKE2b-256 d9768640ee60b9ffea3a4efbff815a06a612349c6db1b53ff85f383a279a0768

See more details on using hashes here.

Provenance

The following attestation bundles were made for confantic-1.0.0.tar.gz:

Publisher: python-publish.yml on Verdant-Evolution/confantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file confantic-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: confantic-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for confantic-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77bdf46276c6d03cfa5310c74ebcb1715ef7855e9eae5b945a73aaa2d5586e42
MD5 eac73b313d3b1a60d72559171551e7b4
BLAKE2b-256 1aeb481e5aedbc08d40fa708194395497ad35f25ef45093871e7c0aba2827fe8

See more details on using hashes here.

Provenance

The following attestation bundles were made for confantic-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on Verdant-Evolution/confantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page