--- id: imperfect version: "0.4.0" license: MIT license_treatment: permissive maintenance: aging --- # imperfect — A CST-based config editor for configparser License: permissive · Maintenance: aging · Downloads: 745.7K/mo ## What it is and what it does imperfect is a CST-based configuration file editor designed to work with files that follow the configparser format (INI-style). Unlike standard configparser, which reads and discards formatting, imperfect parses the file into a tree of nodes that preserves every detail—whitespace, comments, line breaks—so you can make surgical edits and write the file back without losing its original structure and readability. You parse a file with `parse_string()`, then manipulate sections and entries directly. For simple cases, you can use `set_value()` to add or change a key-value pair. For precise control over placement and formatting, you construct `ConfigEntry` and `ValueLine` objects with explicit whitespace control, then insert them into the tree. The package follows configparser's quirks for compatibility, including lenient section name parsing and specific whitespace handling conventions. It requires Python 3.8 or later and depends only on moreorless for diff utilities. Use it for: - Programmatically update setup.cfg while preserving developer comments and formatting - Build configuration management tools that need to edit INI files without destroying readability - Automated code generation or build-system integration that modifies config files in place - Testing frameworks that need to verify or modify configuration files while keeping diffs human-readable ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Parses and edits configparser-compatible INI files while preserving whitespace, comments, and formatting, operating as a concrete syntax tree (CST) rather than a lossy key-value store. Yes, if you need to edit INI-format config files programmatically and preserving formatting matters. The package is stable, low-friction to install, and solves a real problem that standard configparser cannot. The aging maintenance status (477 days since last release) is not a blocker for a mature tool, but verify it handles your specific INI dialect before relying on it in production. ## Install pip install imperfect uv add imperfect poetry add imperfect ## Installing imperfect Before you install: Low friction: pure Python wheel with a single runtime dependency (moreorless). Maintenance status is aging—last release was 477 days ago, though the repository remains active and stable since its initial 2019 release. License in practice: MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions, making it suitable for both open-source and commercial projects. Quickstart: import imperfect with open("setup.cfg") as f: data = f.read() conf = imperfect.parse_string(data) conf.set_value("metadata", "long_description_content_type", "text/markdown") with open("setup.cfg", "w") as f: f.write(conf.text) Requires Python 3.8 or later Verify before relying: - Whether the CST implementation handles all edge cases in real-world setup.cfg or other INI files beyond the hypothesis-tested scenarios - Performance characteristics when editing large or deeply nested configuration files ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 745.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags ini file editor preserving comments, configparser CST parser, edit config files preserve formatting, setup.cfg programmatic editing, whitespace-preserving ini parser, config-management, cst-parser [View on SkillFed](https://skillfed.io/packages/imperfect) · [View on PyPI](https://pypi.org/project/imperfect/)