@@ -11,9 +11,10 @@ confkit is a Python library for type-safe configuration management using descrip
1111- ` Config ` descriptor (` config.py ` ): The main descriptor class that handles getting/setting values in config files
1212- ` ConfigContainerMeta ` (` config.py ` ): Metaclass that enables setting Config descriptors on class variables
1313- ` BaseDataType ` and implementations (` data_types.py ` ): Type converters for different data types
14- - ` ConfkitParser ` protocol (` ext/parsers.py ` ): Protocol defining the parser interface
15- - ` MsgspecParser ` (` ext/parsers.py ` ): Parser for JSON, YAML, and TOML files
16- - ` EnvParser ` (` ext/parsers.py ` ): Parser for environment variables and .env files
14+ - ` ConfkitParser ` protocol (` parsers.py ` ): Defines the unified parser interface for all configuration file formats (INI, JSON, YAML, TOML, .env)
15+ - ` IniParser ` (` parsers.py ` ): Adapter for Python's built-in ConfigParser (INI files)
16+ - ` MsgspecParser ` (` ext/parsers.py ` ): Adapter for JSON, YAML, and TOML files using msgspec
17+ - ` EnvParser ` (` parsers.py ` ): Adapter for environment variables and .env files
1718- ` sentinels.py ` : Provides the ` UNSET ` sentinel value for representing unset values
1819- ` exceptions.py ` : Custom exceptions for configuration errors
1920- ` watcher.py ` : File watching functionality to detect config file changes
@@ -44,6 +45,8 @@ uv sync --group test
4445``` bash
4546# Run linting
4647ruff check .
48+ # Fix issues using
49+ ruff check . --fix --unsafe-fixes
4750# Update dependencies and run tests
4851uv sync --upgrade --group dev; uv run pytest .
4952```
@@ -172,33 +175,26 @@ The `with_setting` approach is more type-safe as it references an actual descrip
172175
173176### Required Initialization
174177
175- Always initialize Config with a file path before use. The parser can be set explicitly or will be auto-detected based on file extension:
178+ Always initialize Config with a file path before use. The parser is auto-detected based on file extension:
176179
177180``` python
178181from pathlib import Path
179182from confkit import Config
180183
181- # Option 1: Auto-detect parser based on file extension
182- Config.set_file(Path(" config.ini" )) # Uses ConfigParser
184+ # Parser is auto-detected based on file extension
185+ Config.set_file(Path(" config.ini" )) # Uses IniParser
183186Config.set_file(Path(" config.json" )) # Uses MsgspecParser
184187Config.set_file(Path(" config.yaml" )) # Uses MsgspecParser
185188Config.set_file(Path(" config.toml" )) # Uses MsgspecParser
186- Config.set_file(Path(" .env" )) # Uses EnvParser
187-
188- # Option 2: Explicitly set parser (not recommended unless it's absolutely required.)
189- from configparser import ConfigParser
190- parser = ConfigParser()
191- Config.set_parser(parser)
192- Config.set_file(Path(" config.ini" ))
193189```
194190
195191### Supported File Formats
196192
197- - ** INI files** (` .ini ` ): Uses Python's ` ConfigParser ` , supports sections
193+ - ** INI files** (` .ini ` ): Uses ` IniParser ` , supports sections
198194- ** JSON files** (` .json ` ): Uses ` MsgspecParser ` , requires ` msgspec ` extra
199195- ** YAML files** (` .yaml ` , ` .yml ` ): Uses ` MsgspecParser ` , requires ` msgspec ` extra
200196- ** TOML files** (` .toml ` ): Uses ` MsgspecParser ` , requires ` msgspec ` extra
201- - ** Environment files** (` .env ` ): Uses ` EnvParser ` , no sections (flat key-value pairs)
197+ - ** Environment files** (` .env ` ): Uses ` EnvParser ` , no sections (flat key-value pairs) — not auto-detected by ` set_file `
202198
203199### List Type Handling
204200
0 commit comments