confkit 2.1.0__tar.gz → 2.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- confkit-2.1.1/.github/workflows/bump-version-by-labels.yml +34 -0
- confkit-2.1.1/.github/workflows/docs.yml +30 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/workflows/test.yml +16 -0
- confkit-2.1.1/LICENSE +16 -0
- {confkit-2.1.0 → confkit-2.1.1}/PKG-INFO +10 -8
- {confkit-2.1.0 → confkit-2.1.1}/README.md +6 -6
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/custom_data_type.md +2 -2
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/data_types.md +2 -2
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/decorators.md +2 -2
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/enums.md +1 -1
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/index.md +1 -1
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/list_types.md +1 -1
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/optional_values.md +1 -1
- {confkit-2.1.0 → confkit-2.1.1}/docs/index.md +5 -5
- confkit-2.1.1/docs/markdown.md +111 -0
- {confkit-2.1.0 → confkit-2.1.1}/docs/reference/config.md +13 -13
- confkit-2.1.1/docs/reference/data_types.md +77 -0
- {confkit-2.1.0 → confkit-2.1.1}/docs/reference/exceptions.md +2 -2
- {confkit-2.1.0 → confkit-2.1.1}/docs/usage.md +7 -7
- {confkit-2.1.0 → confkit-2.1.1}/examples/custom_data_type.py +4 -4
- {confkit-2.1.0 → confkit-2.1.1}/examples/nested_config.py +2 -2
- {confkit-2.1.0 → confkit-2.1.1}/pyproject.toml +7 -2
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/data_types.py +14 -6
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_data_types.py +2 -0
- {confkit-2.1.0 → confkit-2.1.1}/uv.lock +62 -13
- confkit-2.1.1/zensical.toml +56 -0
- confkit-2.1.0/.github/workflows/bump-version-by-labels.yml +0 -74
- confkit-2.1.0/.github/workflows/docs.yml +0 -88
- confkit-2.1.0/docs/reference/data_types.md +0 -77
- {confkit-2.1.0 → confkit-2.1.1}/.bumpversion.toml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/FUNDING.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/copilot-instructions.md +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/dependabot.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/workflows/coverage.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/workflows/gitleaks.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/workflows/lint-public.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/workflows/lint.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/workflows/pypi.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.github/workflows/release.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.gitignore +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.pre-commit-config.yaml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.python-version +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/.vscode/settings.json +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/argparse.md +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/docs/examples/basic.md +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/docs/reference/notes_two_instances.md +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/api.ini +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/argparse_example.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/args.ini +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/basic.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/config.ini +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/data_types.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/database.ini +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/decorators.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/enums.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/example.json +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/example.toml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/example.yaml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/file_change_event.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/list_types.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/multiple_configs.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/nested_example.ini +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/nested_example.json +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/nested_example.toml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/nested_example.yaml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/optional_values.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/other_file_types.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/pydantic_example.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/references.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/examples/url_example.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/mkdocs.yml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/ruff.toml +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/__init__.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/config.py +34 -34
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/exceptions.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/ext/__init__.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/ext/parsers.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/ext/pydantic.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/ext/reference.py +7 -7
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/parsers.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/py.typed +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/sentinels.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/src/confkit/watcher.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/__init__.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/conftest.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_config.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_config_classvars.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_config_decorators.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_config_detect_parser.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_enum_allowed_values.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_enum_auto_conversion.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_env_parser.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_examples_run.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_list_type.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_metaclass.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_msgspec.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_msgspecparser_branches.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_msgspecparser_no_msgspec.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_msgspecparser_read.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_msgspecparser_sections.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_multiple_configurations.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_nested_config.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_on_file_change.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_pydantic_models.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_sentinel.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_two_instances.py +0 -0
- {confkit-2.1.0 → confkit-2.1.1}/tests/test_unreachable_paths.py +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Bump Version By Labels
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [closed]
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
- master
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
bump-version:
|
|
12
|
+
if: github.event.pull_request.merged == true && github.actor != 'github-actions[bot]'
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
contents: write
|
|
16
|
+
pull-requests: write
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
|
|
23
|
+
- name: Install uv
|
|
24
|
+
uses: astral-sh/setup-uv@v4
|
|
25
|
+
with:
|
|
26
|
+
version: "latest"
|
|
27
|
+
|
|
28
|
+
- name: Bump by labels
|
|
29
|
+
uses: HEROgold/bump-by-label@v4.0.0
|
|
30
|
+
with:
|
|
31
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
+
command: "uv version --bump"
|
|
33
|
+
validate: "uv version"
|
|
34
|
+
base_branch: ${{ github.event.pull_request.base.ref }}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
- main
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
pages: write
|
|
10
|
+
id-token: write
|
|
11
|
+
jobs:
|
|
12
|
+
deploy:
|
|
13
|
+
environment:
|
|
14
|
+
name: github-pages
|
|
15
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v7
|
|
19
|
+
- uses: astral-sh/setup-uv@v7
|
|
20
|
+
with:
|
|
21
|
+
enable-cache: true
|
|
22
|
+
- uses: actions/configure-pages@v6
|
|
23
|
+
- run: uv sync --group docs
|
|
24
|
+
- run: uv run pdoc confkit -o docs/api
|
|
25
|
+
- run: uv run zensical build --clean
|
|
26
|
+
- uses: actions/upload-pages-artifact@v5
|
|
27
|
+
with:
|
|
28
|
+
path: site
|
|
29
|
+
- uses: actions/deploy-pages@v5
|
|
30
|
+
id: deployment
|
|
@@ -49,3 +49,19 @@ jobs:
|
|
|
49
49
|
if: steps.cache-pytest.outputs.cache-hit != 'true'
|
|
50
50
|
# Avoid executing examples in CI; they could run untrusted code from PRs
|
|
51
51
|
run: uv run pytest . --ignore=tests/test_examples_run.py
|
|
52
|
+
|
|
53
|
+
# The test job runs with dev dependencies installed, which can hide a
|
|
54
|
+
# runtime import that isn't declared. Import the built wheel on its own.
|
|
55
|
+
clean-install:
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/checkout@v4
|
|
59
|
+
|
|
60
|
+
- name: Install uv
|
|
61
|
+
uses: astral-sh/setup-uv@v7
|
|
62
|
+
|
|
63
|
+
- name: Build the wheel
|
|
64
|
+
run: uv build --wheel -o dist
|
|
65
|
+
|
|
66
|
+
- name: Import it with only its declared dependencies
|
|
67
|
+
run: uv run --isolated --no-project --with dist/*.whl python -c "import confkit"
|
confkit-2.1.1/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-Present HEROgold
|
|
4
|
+
|
|
5
|
+
NON-COMMERCIAL USE PERMISSION:
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, and publish the Software for non-commercial purposes only, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
2. The Software may not be sublicensed, resold, or used to generate commercial revenue under this non-commercial permission.
|
|
10
|
+
|
|
11
|
+
COMMERCIAL USE REQUIREMENT:
|
|
12
|
+
Any use of the Software (in whole or in part) for commercial purposes, including but not limited to use within a company, corporate environment, commercial group, or by a commercial individual, is strictly prohibited without obtaining explicit written permission.
|
|
13
|
+
|
|
14
|
+
Upon obtaining explicit written permission, the licensee (which may be an individual, a specified group, or an entire legal entity/company, depending on the terms of the purchased license) is granted the right to include, modify, and make use of the Software (in whole or in part) within their commercial operations according to the tier purchased.
|
|
15
|
+
|
|
16
|
+
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.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: confkit
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: Lightweight and Easy to use configuration manager for Python projects
|
|
5
5
|
Author: HEROgold
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: typing-extensions>=4.5.0
|
|
7
9
|
Provides-Extra: msgspec
|
|
8
10
|
Requires-Dist: msgspec>=0.20.0; extra == 'msgspec'
|
|
9
11
|
Requires-Dist: pyyaml>=6.0.3; extra == 'msgspec'
|
|
@@ -34,12 +36,12 @@ This ensures that confkit remains compatible with current Python versions while
|
|
|
34
36
|
## What is it?
|
|
35
37
|
|
|
36
38
|
confkit is a Python library that provides type-safe configuration management with automatic type conversion and validation.
|
|
37
|
-
It uses descriptors to define configuration values as class attributes that automatically read from and write to
|
|
39
|
+
It uses descriptors to define configuration values as class attributes that automatically read from and write to configuration files.
|
|
38
40
|
|
|
39
41
|
## What does it do?
|
|
40
42
|
|
|
41
43
|
- Type-safe configuration with automatic type conversion
|
|
42
|
-
- Automatic
|
|
44
|
+
- Automatic configuration file management
|
|
43
45
|
- Default value handling with file persistence
|
|
44
46
|
- Optional value support
|
|
45
47
|
- Enum support (Enum, StrEnum, IntEnum, IntFlag)
|
|
@@ -92,11 +94,11 @@ uv sync --group docs
|
|
|
92
94
|
# Generate API documentation with pdoc
|
|
93
95
|
uv run pdoc confkit -o docs/api
|
|
94
96
|
|
|
95
|
-
# Build documentation site with
|
|
96
|
-
uv run
|
|
97
|
+
# Build documentation site with zensical
|
|
98
|
+
uv run zensical build --clean
|
|
97
99
|
|
|
98
100
|
# Or serve locally for live preview (with auto-reload)
|
|
99
|
-
uv run
|
|
101
|
+
uv run zensical serve
|
|
100
102
|
```
|
|
101
103
|
|
|
102
104
|
Documentation is automatically built and deployed to GitHub Pages when changes are pushed to the `master` branch.
|
|
@@ -105,5 +107,5 @@ Documentation is automatically built and deployed to GitHub Pages when changes a
|
|
|
105
107
|
|
|
106
108
|
1. Update relevant `.md` files in `docs/` directory (examples, reference, etc.)
|
|
107
109
|
2. Run `uv run pdoc confkit -o docs/api` to regenerate API documentation
|
|
108
|
-
3. Preview changes with `uv run
|
|
110
|
+
3. Preview changes with `uv run zensical serve` and verify at `http://127.0.0.1:8000`
|
|
109
111
|
4. Commit both code and documentation changes together
|
|
@@ -20,12 +20,12 @@ This ensures that confkit remains compatible with current Python versions while
|
|
|
20
20
|
## What is it?
|
|
21
21
|
|
|
22
22
|
confkit is a Python library that provides type-safe configuration management with automatic type conversion and validation.
|
|
23
|
-
It uses descriptors to define configuration values as class attributes that automatically read from and write to
|
|
23
|
+
It uses descriptors to define configuration values as class attributes that automatically read from and write to configuration files.
|
|
24
24
|
|
|
25
25
|
## What does it do?
|
|
26
26
|
|
|
27
27
|
- Type-safe configuration with automatic type conversion
|
|
28
|
-
- Automatic
|
|
28
|
+
- Automatic configuration file management
|
|
29
29
|
- Default value handling with file persistence
|
|
30
30
|
- Optional value support
|
|
31
31
|
- Enum support (Enum, StrEnum, IntEnum, IntFlag)
|
|
@@ -78,11 +78,11 @@ uv sync --group docs
|
|
|
78
78
|
# Generate API documentation with pdoc
|
|
79
79
|
uv run pdoc confkit -o docs/api
|
|
80
80
|
|
|
81
|
-
# Build documentation site with
|
|
82
|
-
uv run
|
|
81
|
+
# Build documentation site with zensical
|
|
82
|
+
uv run zensical build --clean
|
|
83
83
|
|
|
84
84
|
# Or serve locally for live preview (with auto-reload)
|
|
85
|
-
uv run
|
|
85
|
+
uv run zensical serve
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
Documentation is automatically built and deployed to GitHub Pages when changes are pushed to the `master` branch.
|
|
@@ -91,5 +91,5 @@ Documentation is automatically built and deployed to GitHub Pages when changes a
|
|
|
91
91
|
|
|
92
92
|
1. Update relevant `.md` files in `docs/` directory (examples, reference, etc.)
|
|
93
93
|
2. Run `uv run pdoc confkit -o docs/api` to regenerate API documentation
|
|
94
|
-
3. Preview changes with `uv run
|
|
94
|
+
3. Preview changes with `uv run zensical serve` and verify at `http://127.0.0.1:8000`
|
|
95
95
|
4. Commit both code and documentation changes together
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
Shows how to create and use a custom [
|
|
5
|
+
Shows how to create and use a custom [BaseDataType](/confkit/api/confkit.html#BaseDataType) implementation.
|
|
6
6
|
|
|
7
7
|
- Normalize and persist a value in a consistent representation
|
|
8
8
|
- Demonstrate the required `convert` method
|
|
@@ -20,7 +20,7 @@ Config.set_file(Path("config.ini"))
|
|
|
20
20
|
|
|
21
21
|
class UpperString(BaseDataType[str]):
|
|
22
22
|
"""String that is always stored / returned in UPPER CASE."""
|
|
23
|
-
def convert(self, value: str) -> str: # raw
|
|
23
|
+
def convert(self, value: str) -> str: # raw configuration -> normalized
|
|
24
24
|
return str(value).upper()
|
|
25
25
|
|
|
26
26
|
def __str__(self, value: str): # normalized -> persisted string
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
Showcases the breadth of built-in and helper data types:
|
|
6
6
|
|
|
7
7
|
- Explicit vs implicit (auto-detected) types
|
|
8
|
-
- Numeric formatting ([Hex](
|
|
8
|
+
- Numeric formatting ([Hex](/confkit/api/confkit.html#Hex), [Octal](/confkit/api/confkit.html#Octal), [Binary](/confkit/api/confkit.html#Binary))
|
|
9
9
|
- Custom base integers (encoded as `<base>c<value>` in the file)
|
|
10
|
-
- Bytes → integer conversion via [
|
|
10
|
+
- Bytes → integer conversion via [Binary](/confkit/api/confkit.html#Binary)
|
|
11
11
|
|
|
12
12
|
## Running
|
|
13
13
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
Shows how to inject configuration values into functions using decorators:
|
|
6
6
|
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
7
|
+
- [@Config.with_setting(descriptor)](/confkit/api/confkit.html#Config.with_setting) — injects kwarg named after descriptor
|
|
8
|
+
- [@Config.with_kwarg(section, option, kwarg_name, default)](/confkit/api/confkit.html#Config.with_kwarg) — inject by strings + custom kwarg name
|
|
9
9
|
|
|
10
10
|
## Running
|
|
11
11
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Demonstrates enum support:
|
|
6
6
|
|
|
7
|
-
- [
|
|
7
|
+
- [StrEnum](/confkit/api/confkit.html#StrEnum), [IntEnum](/confkit/api/confkit.html#IntEnum), [IntFlag](/confkit/api/confkit.html#IntFlag), usage via dedicated data types
|
|
8
8
|
- Optional enum values
|
|
9
9
|
- Bitwise flag composition (`Permission`)
|
|
10
10
|
- **Self-documenting config files** with inline comments showing all allowed enum values
|
|
@@ -16,7 +16,7 @@ All examples assume you are in the project root and have dependencies installed
|
|
|
16
16
|
uv run python examples/basic.py
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
> If you are editing examples and want immediate persistence, remember that [
|
|
19
|
+
> If you are editing examples and want immediate persistence, remember that [Config.write_on_edit](/confkit/api/confkit.html#Config.write_on_edit) defaults to `True` unless explicitly disabled.
|
|
20
20
|
|
|
21
21
|
## Example Categories
|
|
22
22
|
|
|
@@ -30,7 +30,7 @@ empty_list =
|
|
|
30
30
|
|
|
31
31
|
## Notes
|
|
32
32
|
|
|
33
|
-
- See [
|
|
33
|
+
- See [List.separator](/confkit/api/confkit.html#List.separator) and [List.escape_char](/confkit/api/confkit.html#List.escape_char) for their default values (explicitly set in the example for clarity).
|
|
34
34
|
- Items containing the separator are escaped when written, then unescaped on read.
|
|
35
35
|
- An explicit empty list with a declared data type stays as a blank line after the equals sign.
|
|
36
36
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Demonstrates nullable / optional configuration patterns:
|
|
6
6
|
|
|
7
|
-
- `optional=True` shorthand vs [
|
|
7
|
+
- `optional=True` shorthand vs [Optional(...)](/confkit/api/confkit.html#Optional) wrapper
|
|
8
8
|
- Optional enums, strings, integers
|
|
9
9
|
- Empty string vs None semantics
|
|
10
10
|
- Cascading defaults & fallback logic
|
|
@@ -10,7 +10,7 @@ This landing page orients you quickly:
|
|
|
10
10
|
| Create a custom data type | Usage Guide: [Adding a New Data Type](usage.md#adding-a-new-data-type) |
|
|
11
11
|
| See all data type converters | [Reference: Data Types](reference/data_types.md) |
|
|
12
12
|
| Decorator utilities | [Usage: Decorators Overview](usage.md#decorators-overview) |
|
|
13
|
-
| API by symbol | [Generated API (pdoc)](
|
|
13
|
+
| API by symbol | [Generated API (pdoc)](/confkit/api/confkit.html) |
|
|
14
14
|
| Contribute / issues | GitHub Repo: [HEROgold/confkit](https://github.com/HEROgold/confkit) |
|
|
15
15
|
|
|
16
16
|
---
|
|
@@ -49,7 +49,7 @@ uv run pytest -q
|
|
|
49
49
|
uv run ruff check .
|
|
50
50
|
uv sync --group docs
|
|
51
51
|
uv run pdoc confkit -o docs/api
|
|
52
|
-
uv run
|
|
52
|
+
uv run zensical build --clean
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
Before opening a PR, ensure:
|
|
@@ -82,13 +82,13 @@ Two complementary views:
|
|
|
82
82
|
|
|
83
83
|
### Full symbol index (pdoc)
|
|
84
84
|
|
|
85
|
-
[confkit API](
|
|
85
|
+
[confkit API](/confkit/api/confkit.html)
|
|
86
86
|
|
|
87
87
|
Use `(pdoc:qual.name)` style links inside docs for deep, stable symbol links
|
|
88
88
|
|
|
89
89
|
```md
|
|
90
|
-
The [MyClass](
|
|
91
|
-
The [do_something](
|
|
90
|
+
The [MyClass](/confkit/api/confkit.html#mypackage.MyClass) class is awesome.
|
|
91
|
+
The [do_something](/confkit/api/confkit.html#mypackage.MyClass.do_something) method is awesome.
|
|
92
92
|
The [](mypackage.MyClass) class is awesome.
|
|
93
93
|
```
|
|
94
94
|
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
icon: simple/markdown
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Markdown in 5min
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
# H1 Header
|
|
11
|
+
## H2 Header
|
|
12
|
+
### H3 Header
|
|
13
|
+
#### H4 Header
|
|
14
|
+
##### H5 Header
|
|
15
|
+
###### H6 Header
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Text formatting
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
**bold text**
|
|
22
|
+
*italic text*
|
|
23
|
+
***bold and italic***
|
|
24
|
+
~~strikethrough~~
|
|
25
|
+
`inline code`
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Links and images
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
[Link text](https://example.com)
|
|
32
|
+
[Link with title](https://example.com "Hover title")
|
|
33
|
+

|
|
34
|
+

|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Lists
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Unordered:
|
|
41
|
+
|
|
42
|
+
- Item 1
|
|
43
|
+
- Item 2
|
|
44
|
+
- Nested item
|
|
45
|
+
|
|
46
|
+
Ordered:
|
|
47
|
+
|
|
48
|
+
1. First item
|
|
49
|
+
2. Second item
|
|
50
|
+
3. Third item
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Blockquotes
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
> This is a blockquote
|
|
57
|
+
> Multiple lines
|
|
58
|
+
>> Nested quote
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Code blocks
|
|
62
|
+
|
|
63
|
+
````
|
|
64
|
+
```javascript
|
|
65
|
+
function hello() {
|
|
66
|
+
console.log("Hello, world!");
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
````
|
|
70
|
+
|
|
71
|
+
## Tables
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
| Header 1 | Header 2 | Header 3 |
|
|
75
|
+
|----------|----------|----------|
|
|
76
|
+
| Row 1 | Data | Data |
|
|
77
|
+
| Row 2 | Data | Data |
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Horizontal rule
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
---
|
|
84
|
+
or
|
|
85
|
+
***
|
|
86
|
+
or
|
|
87
|
+
___
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Task lists
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
- [x] Completed task
|
|
94
|
+
- [ ] Incomplete task
|
|
95
|
+
- [ ] Another task
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Escaping characters
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
Use backslash to escape: \* \_ \# \`
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Line breaks
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
End a line with two spaces
|
|
108
|
+
to create a line break.
|
|
109
|
+
|
|
110
|
+
Or use a blank line for a new paragraph.
|
|
111
|
+
```
|
|
@@ -8,31 +8,31 @@ This section provides curated guidance around the core `Config` descriptor and i
|
|
|
8
8
|
|
|
9
9
|
## Core Class
|
|
10
10
|
|
|
11
|
-
- [
|
|
11
|
+
- [Config](/confkit/api/confkit.html#Config) – Descriptor managing reading/writing typed values.
|
|
12
12
|
|
|
13
13
|
## Lifecycle / Initialization Helpers
|
|
14
14
|
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
- [
|
|
15
|
+
- [Config.set_parser](/confkit/api/confkit.html#Config.set_parser)
|
|
16
|
+
- [Config.set_file](/confkit/api/confkit.html#Config.set_file)
|
|
17
|
+
- [Config.write](/confkit/api/confkit.html#Config.write)
|
|
18
18
|
|
|
19
19
|
## Runtime Flags
|
|
20
20
|
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
21
|
+
- [Config.validate_types](/confkit/api/confkit.html#Config.validate_types)
|
|
22
|
+
- [Config.write_on_edit](/confkit/api/confkit.html#Config.write_on_edit)
|
|
23
23
|
|
|
24
24
|
## Decorators
|
|
25
25
|
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
29
|
-
- [
|
|
26
|
+
- [Config.set](/confkit/api/confkit.html#Config.set) – Always set a value before calling a function.
|
|
27
|
+
- [Config.default](/confkit/api/confkit.html#Config.default) – Set only when unset.
|
|
28
|
+
- [Config.with_setting](/confkit/api/confkit.html#Config.with_setting) – Inject an existing descriptor value as a kwarg.
|
|
29
|
+
- [Config.with_kwarg](/confkit/api/confkit.html#Config.with_kwarg) – (Named `with_kwarg` in code; often described as `with_kwarg`) inject by section/setting with optional rename & default.
|
|
30
30
|
|
|
31
31
|
## Internal Validation (Selected)
|
|
32
32
|
|
|
33
|
-
- [
|
|
34
|
-
- [
|
|
35
|
-
- [
|
|
33
|
+
- [Config.validate_file](/confkit/api/confkit.html#Config.validate_file)
|
|
34
|
+
- [Config.validate_parser](/confkit/api/confkit.html#Config.validate_parser)
|
|
35
|
+
- [Config.validate_strict_type](/confkit/api/confkit.html#Config.validate_strict_type)
|
|
36
36
|
|
|
37
37
|
> Tip: Use the decorators for imperative flows and prefer descriptor attributes for normal configuration access.
|
|
38
38
|
>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Data Types
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Data Types
|
|
6
|
+
|
|
7
|
+
confkit uses a family of small converter classes to provide type safety and round‑trip serialization.
|
|
8
|
+
|
|
9
|
+
## Base Type
|
|
10
|
+
|
|
11
|
+
- [BaseDataType](/confkit/api/confkit.html#BaseDataType)
|
|
12
|
+
- [BaseDataType.convert](/confkit/api/confkit.html#BaseDataType.convert)
|
|
13
|
+
- [BaseDataType.validate](/confkit/api/confkit.html#BaseDataType.validate)
|
|
14
|
+
- [BaseDataType.cast](/confkit/api/confkit.html#BaseDataType.cast)
|
|
15
|
+
- [BaseDataType.cast_optional](/confkit/api/confkit.html#BaseDataType.cast_optional)
|
|
16
|
+
|
|
17
|
+
## Primitive Converters
|
|
18
|
+
|
|
19
|
+
- [String](/confkit/api/confkit.html#String)
|
|
20
|
+
- [Integer](/confkit/api/confkit.html#Integer)
|
|
21
|
+
- [Float](/confkit/api/confkit.html#Float)
|
|
22
|
+
- [Boolean](/confkit/api/confkit.html#Boolean)
|
|
23
|
+
- [NoneType](/confkit/api/confkit.html#NoneType)
|
|
24
|
+
|
|
25
|
+
## Enum Converters
|
|
26
|
+
|
|
27
|
+
- [Enum](/confkit/api/confkit.html#Enum)
|
|
28
|
+
- [StrEnum](/confkit/api/confkit.html#StrEnum)
|
|
29
|
+
- [IntEnum](/confkit/api/confkit.html#IntEnum)
|
|
30
|
+
- [IntFlag](/confkit/api/confkit.html#IntFlag)
|
|
31
|
+
|
|
32
|
+
All enum types automatically display allowed values as inline comments in the config file, making them self-documenting for end-users. For example:
|
|
33
|
+
|
|
34
|
+
```ini
|
|
35
|
+
log_level = info # allowed: debug, info, warning, error
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The format varies by enum type:
|
|
39
|
+
- **StrEnum**: Shows member values (e.g., `debug, info, warning, error`)
|
|
40
|
+
- **IntEnum/IntFlag**: Shows member names with integer values (e.g., `LOW(0), MEDIUM(5), HIGH(10)`)
|
|
41
|
+
- **Enum**: Shows member names (e.g., `DEBUG, INFO, WARNING, ERROR`)
|
|
42
|
+
|
|
43
|
+
Comments are automatically stripped when reading values, ensuring they don't interfere with parsing.
|
|
44
|
+
|
|
45
|
+
## Number Representation Helpers
|
|
46
|
+
|
|
47
|
+
- [Hex](/confkit/api/confkit.html#Hex)
|
|
48
|
+
- [Octal](/confkit/api/confkit.html#Octal)
|
|
49
|
+
- [Binary](/confkit/api/confkit.html#Binary)
|
|
50
|
+
|
|
51
|
+
## Optional & Composite
|
|
52
|
+
|
|
53
|
+
- [Optional](/confkit/api/confkit.html#Optional)
|
|
54
|
+
- [List](/confkit/api/confkit.html#List)
|
|
55
|
+
|
|
56
|
+
> Design note: `Optional` wraps another `BaseDataType` and returns `None` when a null sentinel is parsed.
|
|
57
|
+
|
|
58
|
+
## Collections
|
|
59
|
+
|
|
60
|
+
- [Tuple](/confkit/api/confkit.html#Tuple)
|
|
61
|
+
- [Set](/confkit/api/confkit.html#Set)
|
|
62
|
+
- [Dict](/confkit/api/confkit.html#Dict)
|
|
63
|
+
|
|
64
|
+
`Tuple`, `Set`, and `Dict` mirror their built‑in counterparts. Allowing for collections to be stored in configuration files.
|
|
65
|
+
|
|
66
|
+
## Date & Time
|
|
67
|
+
|
|
68
|
+
- [DateTime](/confkit/api/confkit.html#DateTime)
|
|
69
|
+
- [Date](/confkit/api/confkit.html#Date)
|
|
70
|
+
- [Time](/confkit/api/confkit.html#Time)
|
|
71
|
+
- [TimeDelta](/confkit/api/confkit.html#TimeDelta)
|
|
72
|
+
|
|
73
|
+
`DateTime`, `Date`, `Time` and `TimeDelta` mirror their built-in counterparts. Allowing to store date information in configuration files.
|
|
74
|
+
|
|
75
|
+
## Custom Type Example
|
|
76
|
+
|
|
77
|
+
- [BaseDataType](/confkit/api/confkit.html#BaseDataType)
|
|
@@ -6,7 +6,7 @@ title: Exceptions
|
|
|
6
6
|
|
|
7
7
|
The library raises a small, focused set of exceptions for invalid defaults and converter errors.
|
|
8
8
|
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
9
|
+
- [InvalidDefaultError](/confkit/api/confkit.html#InvalidDefaultError)
|
|
10
|
+
- [InvalidConverterError](/confkit/api/confkit.html#InvalidConverterError)
|
|
11
11
|
|
|
12
12
|
These both subclass `ValueError` to keep failure modes familiar while allowing precise catching.
|
|
@@ -42,10 +42,10 @@ Config.set_file(Path("config.ini"))
|
|
|
42
42
|
|
|
43
43
|
# 2. Define the custom converter, with a convert method (from str -> your_type)
|
|
44
44
|
class UpperString(BaseDataType[str]):
|
|
45
|
-
def convert(self, value: str) -> str: # str from
|
|
45
|
+
def convert(self, value: str) -> str: # str from configuration -> normalized value
|
|
46
46
|
return str(value).upper()
|
|
47
47
|
|
|
48
|
-
def __str__(self, value: str): # value -> string for
|
|
48
|
+
def __str__(self, value: str): # value -> string for configuration
|
|
49
49
|
return value.upper()
|
|
50
50
|
|
|
51
51
|
# 3. Use the custom datatype inside a config class
|
|
@@ -80,17 +80,17 @@ class Service:
|
|
|
80
80
|
|
|
81
81
|
See also: the dedicated reference pages for cross-linked signatures.
|
|
82
82
|
|
|
83
|
-
## Regenerating API Docs (pdoc +
|
|
83
|
+
## Regenerating API Docs (pdoc + zensical)
|
|
84
84
|
|
|
85
|
-
The
|
|
86
|
-
The `api/` directory inside `docs
|
|
85
|
+
The site is built with `zensical`, which reads the `mkdocs.yml` config and uses the `mkdocstrings` and `pdoc` plugins for deep API symbol cross-references.
|
|
86
|
+
The `api/` directory inside `docs/` is produced by `pdoc`. Regenerate it after changing code-level docstrings or adding new public classes/functions.
|
|
87
87
|
|
|
88
88
|
```bash
|
|
89
|
-
uv run pdoc confkit -o docs
|
|
89
|
+
uv run pdoc confkit -o docs/api --force
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
Key points:
|
|
93
93
|
|
|
94
94
|
1. `--force` overwrites existing output
|
|
95
|
-
2. The
|
|
95
|
+
2. The `pdoc` plugin (configured in `mkdocs.yml` as `pdoc: { api_path: api }`) enables links like `(pdoc:confkit.config.Config)` inside Markdown
|
|
96
96
|
3. Reference pages in `reference/` intentionally use those links for stable deep-links
|
|
@@ -25,17 +25,17 @@ Config.set_file(Path("config.ini"))
|
|
|
25
25
|
class UpperString(BaseDataType[str]):
|
|
26
26
|
"""Custom string data type that normalizes to UPPER CASE.
|
|
27
27
|
|
|
28
|
-
Stored *exactly* as upper case in the
|
|
28
|
+
Stored *exactly* as upper case in the configuration file. Accepts any input that can
|
|
29
29
|
be coerced to str.
|
|
30
30
|
"""
|
|
31
31
|
|
|
32
32
|
def __str__(self) -> str:
|
|
33
|
-
# Called when storing data in the
|
|
33
|
+
# Called when storing data in the configuration;
|
|
34
34
|
return self.value.upper()
|
|
35
35
|
|
|
36
36
|
def convert(self, value: str) -> str:
|
|
37
37
|
"""Convert input to upper case string."""
|
|
38
|
-
# Called when reading from
|
|
38
|
+
# Called when reading from configuration
|
|
39
39
|
return value.upper()
|
|
40
40
|
|
|
41
41
|
def validate(self) -> bool:
|
|
@@ -68,6 +68,6 @@ if __name__ == "__main__":
|
|
|
68
68
|
print("shout_name:", config.shout_name)
|
|
69
69
|
print("project:", config.project)
|
|
70
70
|
|
|
71
|
-
# Show underlying
|
|
71
|
+
# Show underlying configuration content (optional diagnostic)
|
|
72
72
|
ini_text = Path("config.ini").read_text(encoding="utf-8")
|
|
73
73
|
print("\nRaw config.ini contents:\n" + ini_text)
|
|
@@ -89,8 +89,8 @@ print(f"IPv4 netmask: {ServerConfig.Network.IPv4.netmask}")
|
|
|
89
89
|
print(f"IPv6 address: {ServerConfig.Network.IPv6.address}")
|
|
90
90
|
print(f"IPv6 prefix: {ServerConfig.Network.IPv6.prefix}")
|
|
91
91
|
|
|
92
|
-
# Example 3:
|
|
93
|
-
print("\n=== Nested
|
|
92
|
+
# Example 3: configuration files with dot notation
|
|
93
|
+
print("\n=== Nested configuration Configuration (using dot notation) ===")
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
class IniConfig(Config[T]):
|