🛠️ pytools
A modular collection of Python utilities for Typer, Pydantic, and Debugging. Built for high-performance developer workflows using uv and hatchling.
pytools is designed as a "buffet" library—install only the submodules you need to keep your project dependencies lean.
🚀 Quick Start
Add pytools to your project using uv. You can choose specific "extras" to pull in only the dependencies required for that module.
# Install just the Typer utilities (and their deps)
uv add "pytools[typer] @ git+ssh://git@github.com/buchanan-solutions/pytools.git"
# Install everything
uv add "pytools[all] @ git+ssh://git@github.com/buchanan-solutions/pytools.git"
📦 Submodules
| Extra | Description | Key Dependencies |
|---|---|---|
core |
Foundational logic used by all modules. | None (Std Lib only) |
typer |
CLI helpers, context management, and rich logging. | typer, rich, python-dotenv |
pydantic |
Custom validators and base model configurations. | pydantic |
pydantic-settings |
Environment management and config loading. | pydantic-settings |
debugging |
Enhanced print utilities and object inspection. | icecream |
pytools.logging
Phased logging: build a pure LoggingState with bootstrap, adjust it, then call apply_state to activate the stdlib runtime. The same state can be exported for worker processes (for example Uvicorn log_config).
Quick usage:
import logging
from pytools.logging import bootstrap, merge_logger_levels, set_root_level
from pytools.logging.apply import apply_state
state = bootstrap(root_level=logging.INFO, rich=True)
state = merge_logger_levels(state, {"my.package": logging.DEBUG})
state = set_root_level(state, logging.DEBUG)
apply_state(state)
Important — handlers are not objects in config: bootstrap(..., handlers=...) and LoggingState.handlers follow the standard library’s logging.config.dictConfig shape. You pass handler definitions (dicts), not live logging.Handler instances. Custom handlers are wired with a "()": "dotted.import.path.to_callable" entry: that string must resolve to a callable that returns a logging.Handler (often a zero-argument function). At apply time, dictConfig imports that callable and invokes it. Closures over module-level state in your package are fine; the constraint is that the config tree itself must stay serializable as plain dicts and strings (so worker processes and export_config stay coherent).
Default console handler when you omit handlers: colored stderr (create_colored_level_handler), or Rich (create_rich_console_handler) when rich=True.
For step-by-step examples (CLI, Uvicorn, custom handler factories), see src/pytools/logging/USAGE.md.
pytools.typer
from pytools.typer.utils.get_from_ctx import get_from_ctx
from my_app.models import Config
@app.command()
def run(ctx: typer.Context):
config = get_from_ctx(ctx, "config", Config)
pytools.debugging
from pytools.debugging.debug_print import debug_print
data = {"status": "success", "meta": [1, 2, 3]}
debug_print(data)
🛠️ Development
This project uses the src layout and hatchling backend.
# Clone and sync environment
git clone https://github.com/your-org/pytools.git
cd pytools
uv sync --all-extras
# Run tests
uv run pytest
📜 License
MIT © 2026 Buchanan Information Systems Inc.
Metadata
Release files for buchanan-solutions-pytools 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| buchanan_solutions_pytools-0.2.4.tar.gz | 62.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| buchanan_solutions_pytools-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 110.6 kB
Release files / buchanan_solutions_pytools-0.2.4.tar.gz
| Download URL | buchanan_solutions_pytools-0.2.4.tar.gz |
|---|---|
| Size | 62.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4ec4a6e4422592e2d5d86090c9bfc3c7f508ab71c22f28cbae3965e5d3891d0
|
|
BLAKE2b-256 checksum How to use checksums |
894a6c7e74558289ff55ece8552213e3f18ee2feff76d56b01a63126868075d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.5 cpython/3.13.9 HTTPX/0.28.1
|
Release files / buchanan_solutions_pytools-0.2.4-py3-none-any.whl
| Download URL | buchanan_solutions_pytools-0.2.4-py3-none-any.whl |
|---|---|
| Size | 47.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
535195c415776cfdcfd76ca0f9fac6d4cb83ba4a28baad9741c222dd8259da3d
|
|
BLAKE2b-256 checksum How to use checksums |
20fa68e9838589cf61c22200f5c334a86df54ba752ae975b947ee1c274203bce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.5 cpython/3.13.9 HTTPX/0.28.1
|
Security for buchanan-solutions-pytools 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.