rn-forge-commons 0.8.0__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.

Potentially problematic release.


This version of rn-forge-commons might be problematic. Click here for more details.

Files changed (47) hide show
  1. rn_forge_commons-0.8.0/LICENSE +21 -0
  2. rn_forge_commons-0.8.0/PKG-INFO +250 -0
  3. rn_forge_commons-0.8.0/README.md +192 -0
  4. rn_forge_commons-0.8.0/pyproject.toml +96 -0
  5. rn_forge_commons-0.8.0/pyproject.toml.orig +83 -0
  6. rn_forge_commons-0.8.0/src/rn_forge/commons/__init__.py +130 -0
  7. rn_forge_commons-0.8.0/src/rn_forge/commons/config.py +442 -0
  8. rn_forge_commons-0.8.0/src/rn_forge/commons/exceptions.py +84 -0
  9. rn_forge_commons-0.8.0/src/rn_forge/commons/findings.py +71 -0
  10. rn_forge_commons-0.8.0/src/rn_forge/commons/fs/__init__.py +1 -0
  11. rn_forge_commons-0.8.0/src/rn_forge/commons/fs/blocks.py +228 -0
  12. rn_forge_commons-0.8.0/src/rn_forge/commons/fs/documents.py +814 -0
  13. rn_forge_commons-0.8.0/src/rn_forge/commons/fs/hashing.py +26 -0
  14. rn_forge_commons-0.8.0/src/rn_forge/commons/fs/locks.py +110 -0
  15. rn_forge_commons-0.8.0/src/rn_forge/commons/fs/paths.py +326 -0
  16. rn_forge_commons-0.8.0/src/rn_forge/commons/fs/state.py +207 -0
  17. rn_forge_commons-0.8.0/src/rn_forge/commons/generation/__init__.py +34 -0
  18. rn_forge_commons-0.8.0/src/rn_forge/commons/generation/apply.py +238 -0
  19. rn_forge_commons-0.8.0/src/rn_forge/commons/generation/artifacts.py +296 -0
  20. rn_forge_commons-0.8.0/src/rn_forge/commons/generation/plan.py +166 -0
  21. rn_forge_commons-0.8.0/src/rn_forge/commons/generation/templated.py +59 -0
  22. rn_forge_commons-0.8.0/src/rn_forge/commons/integration/__init__.py +5 -0
  23. rn_forge_commons-0.8.0/src/rn_forge/commons/integration/messaging.py +84 -0
  24. rn_forge_commons-0.8.0/src/rn_forge/commons/integration/objects.py +118 -0
  25. rn_forge_commons-0.8.0/src/rn_forge/commons/integration/resilience.py +315 -0
  26. rn_forge_commons-0.8.0/src/rn_forge/commons/integration/secrets.py +78 -0
  27. rn_forge_commons-0.8.0/src/rn_forge/commons/lang/__init__.py +7 -0
  28. rn_forge_commons-0.8.0/src/rn_forge/commons/lang/collections.py +827 -0
  29. rn_forge_commons-0.8.0/src/rn_forge/commons/lang/dataclasses.py +495 -0
  30. rn_forge_commons-0.8.0/src/rn_forge/commons/lang/models.py +145 -0
  31. rn_forge_commons-0.8.0/src/rn_forge/commons/lang/reflection.py +229 -0
  32. rn_forge_commons-0.8.0/src/rn_forge/commons/lang/types.py +52 -0
  33. rn_forge_commons-0.8.0/src/rn_forge/commons/lang/utils.py +300 -0
  34. rn_forge_commons-0.8.0/src/rn_forge/commons/logging/__init__.py +26 -0
  35. rn_forge_commons-0.8.0/src/rn_forge/commons/logging/logger.py +1057 -0
  36. rn_forge_commons-0.8.0/src/rn_forge/commons/logging/structlog.py +196 -0
  37. rn_forge_commons-0.8.0/src/rn_forge/commons/py.typed +0 -0
  38. rn_forge_commons-0.8.0/src/rn_forge/commons/runtime/__init__.py +5 -0
  39. rn_forge_commons-0.8.0/src/rn_forge/commons/runtime/console.py +260 -0
  40. rn_forge_commons-0.8.0/src/rn_forge/commons/runtime/environment.py +119 -0
  41. rn_forge_commons-0.8.0/src/rn_forge/commons/runtime/plugins.py +77 -0
  42. rn_forge_commons-0.8.0/src/rn_forge/commons/runtime/subprocess.py +403 -0
  43. rn_forge_commons-0.8.0/src/rn_forge/commons/runtime/tasks.py +356 -0
  44. rn_forge_commons-0.8.0/src/rn_forge/commons/testing.py +143 -0
  45. rn_forge_commons-0.8.0/src/rn_forge/commons/text/__init__.py +7 -0
  46. rn_forge_commons-0.8.0/src/rn_forge/commons/text/markdown.py +182 -0
  47. rn_forge_commons-0.8.0/src/rn_forge/commons/text/templates.py +186 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rohit Narayanan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,250 @@
1
+ Metadata-Version: 2.4
2
+ Name: rn-forge-commons
3
+ Version: 0.8.0
4
+ Summary: Shared, framework-agnostic utilities for Python programming
5
+ Author: Rohit Narayanan
6
+ Author-email: Rohit Narayanan <rohit.nn@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Typing :: Typed
16
+ Requires-Dist: ruamel-yaml[oldlibyaml]>=0.19.1
17
+ Requires-Dist: tomlkit>=0.15.0
18
+ Requires-Dist: verboselogs>=1.7
19
+ Requires-Dist: rich>=15.0.0
20
+ Requires-Dist: dacite>=1.9.2
21
+ Requires-Dist: httpx>=0.28 ; extra == 'all'
22
+ Requires-Dist: jinja2>=3.1.6 ; extra == 'all'
23
+ Requires-Dist: markdown>=3.7 ; extra == 'all'
24
+ Requires-Dist: markdown-it-py>=3.0 ; extra == 'all'
25
+ Requires-Dist: opentelemetry-instrumentation-logging>=0.64b0 ; extra == 'all'
26
+ Requires-Dist: purgatory>=3.0.1 ; extra == 'all'
27
+ Requires-Dist: pydantic>=2.12 ; extra == 'all'
28
+ Requires-Dist: python-json-logger>=4.0.0 ; extra == 'all'
29
+ Requires-Dist: stamina>=25.2.0 ; extra == 'all'
30
+ Requires-Dist: structlog>=25.1.0 ; extra == 'all'
31
+ Requires-Dist: python-json-logger>=4.0.0 ; extra == 'json'
32
+ Requires-Dist: markdown>=3.7 ; extra == 'markdown'
33
+ Requires-Dist: markdown-it-py>=3.0 ; extra == 'markdown'
34
+ Requires-Dist: opentelemetry-instrumentation-logging>=0.64b0 ; extra == 'otel'
35
+ Requires-Dist: pydantic>=2.12 ; extra == 'pydantic'
36
+ Requires-Dist: purgatory>=3.0.1 ; extra == 'resilience'
37
+ Requires-Dist: stamina>=25.2.0 ; extra == 'resilience'
38
+ Requires-Dist: httpx>=0.28 ; extra == 'resilience'
39
+ Requires-Dist: structlog>=25.1.0 ; extra == 'structlog'
40
+ Requires-Dist: jinja2>=3.1.6 ; extra == 'templates'
41
+ Requires-Dist: assertpy>=1.1 ; extra == 'testing'
42
+ Requires-Dist: pytest>=9.1.1 ; extra == 'testing'
43
+ Requires-Python: >=3.14
44
+ Project-URL: Documentation, https://rn-forge.github.io/pykit/packages/rn-forge-commons/latest/
45
+ Project-URL: Source, https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons
46
+ Project-URL: Changelog, https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-commons/CHANGELOG.md
47
+ Project-URL: Issues, https://github.com/rn-forge/pykit/issues
48
+ Provides-Extra: all
49
+ Provides-Extra: json
50
+ Provides-Extra: markdown
51
+ Provides-Extra: otel
52
+ Provides-Extra: pydantic
53
+ Provides-Extra: resilience
54
+ Provides-Extra: structlog
55
+ Provides-Extra: templates
56
+ Provides-Extra: testing
57
+ Description-Content-Type: text/markdown
58
+
59
+ # rn-forge-commons
60
+
61
+ [Documentation](https://rn-forge.github.io/pykit/packages/rn-forge-commons/latest/)
62
+ ·
63
+ [Changelog](https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-commons/CHANGELOG.md)
64
+ ·
65
+ [Source](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons)
66
+ · [All pykit packages](https://rn-forge.github.io/pykit/)
67
+
68
+ Shared, framework-agnostic utilities for Python programming.
69
+
70
+ ## Install
71
+
72
+ Require the package by version range:
73
+
74
+ ```toml
75
+ [project]
76
+ dependencies = ["rn-forge-commons>=0.8,<0.9"]
77
+ ```
78
+
79
+ Optional extras:
80
+
81
+ | Extra | Adds |
82
+ | -- | -- |
83
+ | `json` | JSON-formatted log output (`python-json-logger`) |
84
+ | `pydantic` | Strict pydantic models for configuration documents, with every failure named by dotted path |
85
+ | `otel` | OpenTelemetry logging instrumentation |
86
+ | `testing` | `assertpy` + `pytest` integration helpers |
87
+ | `resilience` | Async circuit breakers and HTTP retries (`purgatory`, `stamina`, `httpx`) |
88
+ | `structlog` | Structured logging over the existing stdlib handlers |
89
+ | `templates` | The Jinja template engine, `rn_forge.commons.text.templates` (`jinja2`) |
90
+ | `markdown` | Markdown structure, `rn_forge.commons.text.markdown` (`markdown`, `markdown-it-py`) |
91
+ | `all` | Everything above |
92
+
93
+ Console log output is Rich-formatted by default (a hard dependency) when stdout
94
+ is a TTY.
95
+
96
+ ## What's inside
97
+
98
+ Modules are grouped by kind of mechanism. Public class names do not encode the
99
+ grouping and are all re-exported from the package facade, so
100
+ `from rn_forge.commons import PathUtils` works regardless of which submodule
101
+ holds it.
102
+
103
+ **Top level**
104
+
105
+ - **`config`** — `Config`: loads JSON/YAML config from a file or directory,
106
+ deep-merges multiple sources, and resolves internal references.
107
+ - **`exceptions`** — `AppException`: structured exception base class for the
108
+ `rn-forge-*` family.
109
+ - **`findings`** — `Finding`, `Severity`: the structured result shape every
110
+ checker and doctor reports in, serialisable for `--json`.
111
+ - **`testing`** — `output_path` fixture and `assertpy` integration, for use from
112
+ `conftest.py`.
113
+
114
+ **`lang/`** — Python objects themselves; no filesystem, no outside world.
115
+
116
+ - **`collections`** — `DictUtils`, `ListUtils`: dot-path get/set, typed dot-path
117
+ reads that treat a wrong-shaped value as absent (`get_mapping`, `get_list`,
118
+ `get_strings`, `get_str`, `get_bool`), layered merge with provenance,
119
+ flatten, structural comparison, sorting, filtering, grouping.
120
+ - **`dataclasses`** — `DataclassMixin`: adds `as_dict()`, `to_json()`,
121
+ `to_yaml()`, `from_dict()` to any `@dataclass`, reconstructing nested
122
+ dataclasses and enum members on the way back. `from_dict()` is **strict**: a
123
+ value whose type does not match its field is rejected as an `AppException`
124
+ naming the offending field. `LenientDataclassMixin`: the same surface with
125
+ type checking off — for a record whose input is known-ragged, and for the
126
+ two annotations dacite cannot see through (a PEP 695 `type` alias, an
127
+ unbound type variable), which the module docstring spells out.
128
+ `StrictDataclassMixin`: type checking plus rejection of unknown keys at
129
+ every nesting level, named by dotted path (`repository.archtype`) — for
130
+ configuration documents.
131
+ - **`models`** (`pydantic` extra) — `StrictModel`, `parse_model`,
132
+ `ModelValidationError`: pydantic models that are strict, frozen and reject
133
+ unknown keys, raising one `AppException` that names every failing key by its
134
+ dotted path. Not on the facade, so `import rn_forge.commons` never loads
135
+ pydantic.
136
+ - **`reflection`** — `ReflectUtils`: fully-qualified name resolution,
137
+ error-message formatting, and stack-frame variable inspection.
138
+ - **`types`** — the recursive `JsonValue` alias.
139
+ - **`utils`** — `AppUtils`, `Base64`: bool parsing, emptiness checks, dynamic
140
+ imports, null-safe attribute access, string joining, unified diffs, and
141
+ base64 encode/decode.
142
+
143
+ **`fs/`** — everything that reads or writes a real file.
144
+
145
+ - **`paths`** — `PathUtils`: atomic writes, backups, temp dirs, repository-root
146
+ discovery and the `assert_within` path-escape guard.
147
+ - **`hashing`** — `ContentHash`: content and file digests, for detecting drift.
148
+ - **`locks`** — `DirectoryLock`, `atomic_symlink`: cross-process serialization
149
+ and atomic publication.
150
+ - **`state`** — `StateStore`: a locked, atomically-written JSON key-to-entry
151
+ store.
152
+ - **`blocks`** — `ManagedBlock`: render, extract and remove a generator-owned
153
+ fenced block inside a file somebody else owns (`.gitignore`, `CLAUDE.md`,
154
+ `mkdocs.yml`), preserving every byte outside the markers.
155
+ - **`documents`** — `JsonUtils`, `YamlUtils`, `DocumentUtils`, `ConfigFormat`:
156
+ JSON/YAML/TOML (de)serialization and file I/O, plus comment-preserving
157
+ round-trip editing of config documents.
158
+
159
+ **`generation/`** — plan, diff and atomic apply of owned files (`Artifact`,
160
+ `plan`, `apply`). Imported directly, never through the facade.
161
+
162
+ **`text/`** — text formats, each module behind its own extra and imported
163
+ directly (never through the facade).
164
+
165
+ - **`markdown`** (`markdown` extra) — `MarkdownUtils`, `MarkdownHeading`,
166
+ `MarkdownTable`: headings and MkDocs-compatible anchors, link and image
167
+ targets, pipe tables with line positions, and text without fenced code.
168
+ - **`templates`** (`templates` extra) — `TemplateEngine`, `RenderError`: strict
169
+ Jinja rendering from a directory or a package, with `autoescape`, a
170
+ process-wide `TemplateEngine.cached` constructor, and `to_toml`/`to_yaml`
171
+ filters.
172
+
173
+ **`logging/`**
174
+
175
+ - **`logging`** — `AppLogger`, `LoggingConfig`: idempotent logging setup via
176
+ `dictConfig`, built on `verboselogs` with a custom `TRACE` level. Console
177
+ records go to **stderr**, so a command's stdout carries only its result.
178
+ - **`structlog`** (`structlog` extra) — `StructLogger`: structured logging over
179
+ the same handlers.
180
+
181
+ **`runtime/`** — the process and its surroundings.
182
+
183
+ - **`environment`** — `Environment`: typed env-var access, plus the
184
+ `require`/`forbid` fail-fast guards a process calls at startup.
185
+ - **`console`** — `AppConsole`, `OutputMode`, `console`: a Rich output facade
186
+ with RICH/PLAIN/ QUIET/JSON modes, semantic helpers, a one-call table
187
+ builder and confirm/prompt/status interaction. Imports no Typer or Click, so
188
+ a script, a worker or a Django management command uses it directly;
189
+ `rn-forge-cli` drives its mode from `--quiet`/`--json`.
190
+ - **`subprocess`** — `Process`: immutable dataclass that runs a subprocess and
191
+ captures return code, stdout, and stderr.
192
+ - **`tasks`** — `Task`, `TaskPool`: parallel task execution via a managed thread
193
+ pool.
194
+ - **`plugins`** — `EntryPointLoader`: failure-isolated entry-point plugin
195
+ discovery.
196
+
197
+ **`integration/`** — protocols for the systems an application talks to.
198
+
199
+ - **`messaging`**, **`objects`**, **`secrets`** — `MessageBus`, `ObjectStore`,
200
+ `SecretStore` and their in-memory implementations.
201
+ - **`resilience`** (`resilience` extra) — async circuit breakers and a retrying
202
+ HTTP client.
203
+
204
+ Import from the top-level package for the curated public API:
205
+
206
+ ```python
207
+ from rn_forge.commons import AppLogger, Config, DictUtils, JsonUtils
208
+
209
+ logger = AppLogger.initialize(root_logger_name="my-service")
210
+ cfg = Config("config")
211
+ logger.info("database.host={}", cfg.get("database.host"))
212
+ ```
213
+
214
+ ### The developer-tooling packages
215
+
216
+ The command-line layer lives in
217
+ [`rn-forge-cli`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-cli)
218
+ and the file-owning tooling in
219
+ [`rn-forge-tooling`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-tooling).
220
+ Both depend on this package; neither is depended on by it, and there are
221
+ deliberately no compatibility re-exports in either direction — that would
222
+ reverse the dependency. `uv run lint-imports` proves it.
223
+
224
+ | Concern | Package |
225
+ | -- | -- |
226
+ | `AppConsole`, Typer app factory, standard options, exit codes, the `[cli]` surface | `rn-forge-cli` |
227
+ | `extract_archive`, the install lifecycle, docs checkers | `rn-forge-tooling` |
228
+
229
+ ## Docs
230
+
231
+ Full API reference and guides are built with mkdocs:
232
+
233
+ ```bash
234
+ uv run --group docs mkdocs serve # or `mkdocs build`
235
+ ```
236
+
237
+ Source lives in
238
+ [`docs/`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons/docs),
239
+ configured via
240
+ [`mkdocs.yml`](https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-commons/mkdocs.yml).
241
+
242
+ ## Development
243
+
244
+ From the repo root or this directory:
245
+
246
+ ```bash
247
+ uv run pytest packages/rn-forge-commons
248
+ uv run ruff check packages/rn-forge-commons
249
+ uv run pyright
250
+ ```
@@ -0,0 +1,192 @@
1
+ # rn-forge-commons
2
+
3
+ [Documentation](https://rn-forge.github.io/pykit/packages/rn-forge-commons/latest/)
4
+ ·
5
+ [Changelog](https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-commons/CHANGELOG.md)
6
+ ·
7
+ [Source](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons)
8
+ · [All pykit packages](https://rn-forge.github.io/pykit/)
9
+
10
+ Shared, framework-agnostic utilities for Python programming.
11
+
12
+ ## Install
13
+
14
+ Require the package by version range:
15
+
16
+ ```toml
17
+ [project]
18
+ dependencies = ["rn-forge-commons>=0.8,<0.9"]
19
+ ```
20
+
21
+ Optional extras:
22
+
23
+ | Extra | Adds |
24
+ | -- | -- |
25
+ | `json` | JSON-formatted log output (`python-json-logger`) |
26
+ | `pydantic` | Strict pydantic models for configuration documents, with every failure named by dotted path |
27
+ | `otel` | OpenTelemetry logging instrumentation |
28
+ | `testing` | `assertpy` + `pytest` integration helpers |
29
+ | `resilience` | Async circuit breakers and HTTP retries (`purgatory`, `stamina`, `httpx`) |
30
+ | `structlog` | Structured logging over the existing stdlib handlers |
31
+ | `templates` | The Jinja template engine, `rn_forge.commons.text.templates` (`jinja2`) |
32
+ | `markdown` | Markdown structure, `rn_forge.commons.text.markdown` (`markdown`, `markdown-it-py`) |
33
+ | `all` | Everything above |
34
+
35
+ Console log output is Rich-formatted by default (a hard dependency) when stdout
36
+ is a TTY.
37
+
38
+ ## What's inside
39
+
40
+ Modules are grouped by kind of mechanism. Public class names do not encode the
41
+ grouping and are all re-exported from the package facade, so
42
+ `from rn_forge.commons import PathUtils` works regardless of which submodule
43
+ holds it.
44
+
45
+ **Top level**
46
+
47
+ - **`config`** — `Config`: loads JSON/YAML config from a file or directory,
48
+ deep-merges multiple sources, and resolves internal references.
49
+ - **`exceptions`** — `AppException`: structured exception base class for the
50
+ `rn-forge-*` family.
51
+ - **`findings`** — `Finding`, `Severity`: the structured result shape every
52
+ checker and doctor reports in, serialisable for `--json`.
53
+ - **`testing`** — `output_path` fixture and `assertpy` integration, for use from
54
+ `conftest.py`.
55
+
56
+ **`lang/`** — Python objects themselves; no filesystem, no outside world.
57
+
58
+ - **`collections`** — `DictUtils`, `ListUtils`: dot-path get/set, typed dot-path
59
+ reads that treat a wrong-shaped value as absent (`get_mapping`, `get_list`,
60
+ `get_strings`, `get_str`, `get_bool`), layered merge with provenance,
61
+ flatten, structural comparison, sorting, filtering, grouping.
62
+ - **`dataclasses`** — `DataclassMixin`: adds `as_dict()`, `to_json()`,
63
+ `to_yaml()`, `from_dict()` to any `@dataclass`, reconstructing nested
64
+ dataclasses and enum members on the way back. `from_dict()` is **strict**: a
65
+ value whose type does not match its field is rejected as an `AppException`
66
+ naming the offending field. `LenientDataclassMixin`: the same surface with
67
+ type checking off — for a record whose input is known-ragged, and for the
68
+ two annotations dacite cannot see through (a PEP 695 `type` alias, an
69
+ unbound type variable), which the module docstring spells out.
70
+ `StrictDataclassMixin`: type checking plus rejection of unknown keys at
71
+ every nesting level, named by dotted path (`repository.archtype`) — for
72
+ configuration documents.
73
+ - **`models`** (`pydantic` extra) — `StrictModel`, `parse_model`,
74
+ `ModelValidationError`: pydantic models that are strict, frozen and reject
75
+ unknown keys, raising one `AppException` that names every failing key by its
76
+ dotted path. Not on the facade, so `import rn_forge.commons` never loads
77
+ pydantic.
78
+ - **`reflection`** — `ReflectUtils`: fully-qualified name resolution,
79
+ error-message formatting, and stack-frame variable inspection.
80
+ - **`types`** — the recursive `JsonValue` alias.
81
+ - **`utils`** — `AppUtils`, `Base64`: bool parsing, emptiness checks, dynamic
82
+ imports, null-safe attribute access, string joining, unified diffs, and
83
+ base64 encode/decode.
84
+
85
+ **`fs/`** — everything that reads or writes a real file.
86
+
87
+ - **`paths`** — `PathUtils`: atomic writes, backups, temp dirs, repository-root
88
+ discovery and the `assert_within` path-escape guard.
89
+ - **`hashing`** — `ContentHash`: content and file digests, for detecting drift.
90
+ - **`locks`** — `DirectoryLock`, `atomic_symlink`: cross-process serialization
91
+ and atomic publication.
92
+ - **`state`** — `StateStore`: a locked, atomically-written JSON key-to-entry
93
+ store.
94
+ - **`blocks`** — `ManagedBlock`: render, extract and remove a generator-owned
95
+ fenced block inside a file somebody else owns (`.gitignore`, `CLAUDE.md`,
96
+ `mkdocs.yml`), preserving every byte outside the markers.
97
+ - **`documents`** — `JsonUtils`, `YamlUtils`, `DocumentUtils`, `ConfigFormat`:
98
+ JSON/YAML/TOML (de)serialization and file I/O, plus comment-preserving
99
+ round-trip editing of config documents.
100
+
101
+ **`generation/`** — plan, diff and atomic apply of owned files (`Artifact`,
102
+ `plan`, `apply`). Imported directly, never through the facade.
103
+
104
+ **`text/`** — text formats, each module behind its own extra and imported
105
+ directly (never through the facade).
106
+
107
+ - **`markdown`** (`markdown` extra) — `MarkdownUtils`, `MarkdownHeading`,
108
+ `MarkdownTable`: headings and MkDocs-compatible anchors, link and image
109
+ targets, pipe tables with line positions, and text without fenced code.
110
+ - **`templates`** (`templates` extra) — `TemplateEngine`, `RenderError`: strict
111
+ Jinja rendering from a directory or a package, with `autoescape`, a
112
+ process-wide `TemplateEngine.cached` constructor, and `to_toml`/`to_yaml`
113
+ filters.
114
+
115
+ **`logging/`**
116
+
117
+ - **`logging`** — `AppLogger`, `LoggingConfig`: idempotent logging setup via
118
+ `dictConfig`, built on `verboselogs` with a custom `TRACE` level. Console
119
+ records go to **stderr**, so a command's stdout carries only its result.
120
+ - **`structlog`** (`structlog` extra) — `StructLogger`: structured logging over
121
+ the same handlers.
122
+
123
+ **`runtime/`** — the process and its surroundings.
124
+
125
+ - **`environment`** — `Environment`: typed env-var access, plus the
126
+ `require`/`forbid` fail-fast guards a process calls at startup.
127
+ - **`console`** — `AppConsole`, `OutputMode`, `console`: a Rich output facade
128
+ with RICH/PLAIN/ QUIET/JSON modes, semantic helpers, a one-call table
129
+ builder and confirm/prompt/status interaction. Imports no Typer or Click, so
130
+ a script, a worker or a Django management command uses it directly;
131
+ `rn-forge-cli` drives its mode from `--quiet`/`--json`.
132
+ - **`subprocess`** — `Process`: immutable dataclass that runs a subprocess and
133
+ captures return code, stdout, and stderr.
134
+ - **`tasks`** — `Task`, `TaskPool`: parallel task execution via a managed thread
135
+ pool.
136
+ - **`plugins`** — `EntryPointLoader`: failure-isolated entry-point plugin
137
+ discovery.
138
+
139
+ **`integration/`** — protocols for the systems an application talks to.
140
+
141
+ - **`messaging`**, **`objects`**, **`secrets`** — `MessageBus`, `ObjectStore`,
142
+ `SecretStore` and their in-memory implementations.
143
+ - **`resilience`** (`resilience` extra) — async circuit breakers and a retrying
144
+ HTTP client.
145
+
146
+ Import from the top-level package for the curated public API:
147
+
148
+ ```python
149
+ from rn_forge.commons import AppLogger, Config, DictUtils, JsonUtils
150
+
151
+ logger = AppLogger.initialize(root_logger_name="my-service")
152
+ cfg = Config("config")
153
+ logger.info("database.host={}", cfg.get("database.host"))
154
+ ```
155
+
156
+ ### The developer-tooling packages
157
+
158
+ The command-line layer lives in
159
+ [`rn-forge-cli`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-cli)
160
+ and the file-owning tooling in
161
+ [`rn-forge-tooling`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-tooling).
162
+ Both depend on this package; neither is depended on by it, and there are
163
+ deliberately no compatibility re-exports in either direction — that would
164
+ reverse the dependency. `uv run lint-imports` proves it.
165
+
166
+ | Concern | Package |
167
+ | -- | -- |
168
+ | `AppConsole`, Typer app factory, standard options, exit codes, the `[cli]` surface | `rn-forge-cli` |
169
+ | `extract_archive`, the install lifecycle, docs checkers | `rn-forge-tooling` |
170
+
171
+ ## Docs
172
+
173
+ Full API reference and guides are built with mkdocs:
174
+
175
+ ```bash
176
+ uv run --group docs mkdocs serve # or `mkdocs build`
177
+ ```
178
+
179
+ Source lives in
180
+ [`docs/`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons/docs),
181
+ configured via
182
+ [`mkdocs.yml`](https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-commons/mkdocs.yml).
183
+
184
+ ## Development
185
+
186
+ From the repo root or this directory:
187
+
188
+ ```bash
189
+ uv run pytest packages/rn-forge-commons
190
+ uv run ruff check packages/rn-forge-commons
191
+ uv run pyright
192
+ ```
@@ -0,0 +1,96 @@
1
+ [project]
2
+ name = "rn-forge-commons"
3
+ version = "0.8.0"
4
+ description = "Shared, framework-agnostic utilities for Python programming"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ classifiers = [
9
+ "Development Status :: 3 - Alpha",
10
+ "Intended Audience :: Developers",
11
+ "Operating System :: OS Independent",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3 :: Only",
14
+ "Programming Language :: Python :: 3.14",
15
+ "Typing :: Typed",
16
+ ]
17
+ requires-python = ">=3.14"
18
+ dependencies = [
19
+ "ruamel.yaml[oldlibyaml]>=0.19.1",
20
+ "tomlkit>=0.15.0",
21
+ "verboselogs>=1.7",
22
+ "rich>=15.0.0",
23
+ "dacite>=1.9.2",
24
+ ]
25
+
26
+ [[project.authors]]
27
+ name = "Rohit Narayanan"
28
+ email = "rohit.nn@gmail.com"
29
+
30
+ [project.optional-dependencies]
31
+ json = ["python-json-logger>=4.0.0"]
32
+ structlog = ["structlog>=25.1.0"]
33
+ resilience = [
34
+ "purgatory>=3.0.1",
35
+ "stamina>=25.2.0",
36
+ "httpx>=0.28",
37
+ ]
38
+ otel = ["opentelemetry-instrumentation-logging>=0.64b0"]
39
+ pydantic = ["pydantic>=2.12"]
40
+ markdown = [
41
+ "markdown>=3.7",
42
+ "markdown-it-py>=3.0",
43
+ ]
44
+ templates = ["jinja2>=3.1.6"]
45
+ testing = [
46
+ "assertpy>=1.1",
47
+ "pytest>=9.1.1",
48
+ ]
49
+ all = [
50
+ "httpx>=0.28",
51
+ "jinja2>=3.1.6",
52
+ "markdown>=3.7",
53
+ "markdown-it-py>=3.0",
54
+ "opentelemetry-instrumentation-logging>=0.64b0",
55
+ "purgatory>=3.0.1",
56
+ "pydantic>=2.12",
57
+ "python-json-logger>=4.0.0",
58
+ "stamina>=25.2.0",
59
+ "structlog>=25.1.0",
60
+ ]
61
+
62
+ [project.urls]
63
+ Documentation = "https://rn-forge.github.io/pykit/packages/rn-forge-commons/latest/"
64
+ Source = "https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons"
65
+ Changelog = "https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-commons/CHANGELOG.md"
66
+ Issues = "https://github.com/rn-forge/pykit/issues"
67
+
68
+ [build-system]
69
+ requires = ["uv_build>=0.11.28,<0.12.0"]
70
+ build-backend = "uv_build"
71
+
72
+ [tool.uv.build-backend]
73
+ module-name = "rn_forge.commons"
74
+
75
+ [tool.uv.sources.rn-forge-commons]
76
+ workspace = true
77
+
78
+ [tool.pytest.ini_options]
79
+ addopts = "-ra --import-mode=importlib"
80
+
81
+ [dependency-groups]
82
+ dev = [
83
+ "assertpy>=1.1",
84
+ "pyright>=1.1.411",
85
+ "pytest>=9.1.1",
86
+ "pytest-cov>=7.1.0",
87
+ "pytest-randomly>=4.1.0",
88
+ "rn-forge-commons[all]",
89
+ "ruff>=0.15.21",
90
+ ]
91
+ docs = [
92
+ "mkdocs>=1.6.1",
93
+ "mkdocs-material>=9.7.6",
94
+ "mkdocstrings[python]>=1.0.6",
95
+ "rn-forge-commons[all]",
96
+ ]
@@ -0,0 +1,83 @@
1
+ [project]
2
+ name = "rn-forge-commons"
3
+ version = "0.8.0"
4
+ description = "Shared, framework-agnostic utilities for Python programming"
5
+ readme = "README.md"
6
+ authors = [{ name = "Rohit Narayanan", email = "rohit.nn@gmail.com" }]
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Developers",
12
+ "Operating System :: OS Independent",
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3 :: Only",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Typing :: Typed",
17
+ ]
18
+ requires-python = ">=3.14"
19
+ dependencies = [
20
+ "ruamel.yaml[oldlibyaml]>=0.19.1",
21
+ "tomlkit>=0.15.0",
22
+ "verboselogs>=1.7",
23
+ "rich>=15.0.0",
24
+ "dacite>=1.9.2",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ json = ["python-json-logger>=4.0.0"]
29
+ structlog = ["structlog>=25.1.0"]
30
+ resilience = ["purgatory>=3.0.1", "stamina>=25.2.0", "httpx>=0.28"]
31
+ otel = ["opentelemetry-instrumentation-logging>=0.64b0"]
32
+ pydantic = ["pydantic>=2.12"]
33
+ markdown = ["markdown>=3.7", "markdown-it-py>=3.0"]
34
+ templates = ["jinja2>=3.1.6"]
35
+ testing = ["assertpy>=1.1", "pytest>=9.1.1"]
36
+ all = [
37
+ "httpx>=0.28",
38
+ "jinja2>=3.1.6",
39
+ "markdown>=3.7",
40
+ "markdown-it-py>=3.0",
41
+ "opentelemetry-instrumentation-logging>=0.64b0",
42
+ "purgatory>=3.0.1",
43
+ "pydantic>=2.12",
44
+ "python-json-logger>=4.0.0",
45
+ "stamina>=25.2.0",
46
+ "structlog>=25.1.0",
47
+ ]
48
+
49
+ [project.urls]
50
+ Documentation = "https://rn-forge.github.io/pykit/packages/rn-forge-commons/latest/"
51
+ Source = "https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons"
52
+ Changelog = "https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-commons/CHANGELOG.md"
53
+ Issues = "https://github.com/rn-forge/pykit/issues"
54
+
55
+ [build-system]
56
+ requires = ["uv_build>=0.11.28,<0.12.0"]
57
+ build-backend = "uv_build"
58
+
59
+ [tool.uv.build-backend]
60
+ module-name = "rn_forge.commons"
61
+
62
+ [tool.uv.sources]
63
+ rn-forge-commons = { workspace = true }
64
+
65
+ [tool.pytest.ini_options]
66
+ addopts = "-ra --import-mode=importlib"
67
+
68
+ [dependency-groups]
69
+ dev = [
70
+ "assertpy>=1.1",
71
+ "pyright>=1.1.411",
72
+ "pytest>=9.1.1",
73
+ "pytest-cov>=7.1.0",
74
+ "pytest-randomly>=4.1.0",
75
+ "rn-forge-commons[all]",
76
+ "ruff>=0.15.21",
77
+ ]
78
+ docs = [
79
+ "mkdocs>=1.6.1",
80
+ "mkdocs-material>=9.7.6",
81
+ "mkdocstrings[python]>=1.0.6",
82
+ "rn-forge-commons[all]",
83
+ ]