Base result and exception tracking utilities for Python.
Project description
Runtime baseline: package version 1.0.0rc2 (
tbot223_base.__version__ == "1.0.0rc2").
tbot223-base
tbot223-base is a small Python base package for exchanging operation results and safe exception payloads across function and module boundaries.
It provides two core pieces:
ResultandResultStatusfor explicitsuccess,failure, andcancelledoutcomes.ExceptionTrackerfor separating internal debug diagnostics from public-safe error payloads.
Design Intent
tbot223-base was shaped by Python boundary-handling needs, not by an attempt to reproduce another language's API.
Rust's Result can be a useful comparison point for readers, but it is not the source model or compatibility target for this package. Here, Result is a Python-style exchange protocol: a small value shape that lets functions pass status, data, context, and error text without guessing how the caller wants to handle the outcome.
ExceptionTracker exists for safe error handling at boundaries. It does not make errors disappear; it keeps rich internal diagnostics available while producing a smaller public payload that avoids traceback, local variable, system, or raw exception leakage.
Who This Is For
This package fits codebases that want:
- a stable result shape for function, service, worker, or module boundaries.
- a lightweight way to return success, failure, and cancellation without inventing a new dictionary shape in each layer.
- public-safe error payloads for APIs, UI surfaces, bot responses, or other untrusted boundaries.
- debug diagnostics that can stay richer than public responses.
- a small typed utility package rather than a framework.
It is especially useful when an operation result is part of the interface between components, not just a local implementation detail.
Trade-offs
Result makes outcomes explicit, but that also means callers and callees must agree to pass and inspect a structured value. For very small scripts or code where normal exceptions are already the clearest control flow, this can be unnecessary ceremony.
ExceptionTracker intentionally separates public and debug payloads. That is safer for public boundaries, but it also means public responses will not contain raw exception messages, traceback frames, local variables, or system information unless you explicitly provide safe public text.
This package is not:
- a Rust-compatible
Resultimplementation. - a pattern-matching or monadic result framework.
- a logging, tracing, metrics, or observability system.
- a replacement for Python exceptions inside purely local control flow.
Installation
python -m pip install --pre "tbot223-base==1.0.0rc2"
For the latest stable release instead, use python -m pip install tbot223-base.
For local development from a source checkout:
python -m pip install -e ".[test,type]"
Quickstart
Create and inspect a result.
from tbot223_base.result import Result, ResultStatus
result: Result[dict[str, int]] = Result(
status=ResultStatus.SUCCESS,
error=None,
context="FetchProfile",
data={"user_id": 1},
)
if result.is_success:
print(result.unwrap())
Return a public-safe exception payload.
from tbot223_base.exception_tracker import ExceptionTracker
tracker = ExceptionTracker()
try:
1 / 0
except Exception as error:
result = tracker.get_public_exception_return(
error,
error_code="DIVIDE_BY_ZERO",
public_message="The calculation could not be completed.",
public_context="Calculator.Divide",
retryable=False,
)
print(result.data)
Documentation
User-facing docs:
- English docs
- Korean docs
- Getting Started
- Executable examples
- Result reference
- ExceptionTracker reference
- API contract
Repository maintenance docs:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tbot223_base-1.0.0rc2.tar.gz.
File metadata
- Download URL: tbot223_base-1.0.0rc2.tar.gz
- Upload date:
- Size: 91.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0522da3f0df66e8e1c2c4c618d104d406be0ccd70045ce4d8b4a0d67da760963
|
|
| MD5 |
ef1606d85c98431f89b4fc214aed495a
|
|
| BLAKE2b-256 |
6a7ceef4c8b5d6ff2c21792129e47c35128cae8e3c92a5088d48adc4406f713a
|
Provenance
The following attestation bundles were made for tbot223_base-1.0.0rc2.tar.gz:
Publisher:
publish.yml on Tbot223/tbot223-base
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tbot223_base-1.0.0rc2.tar.gz -
Subject digest:
0522da3f0df66e8e1c2c4c618d104d406be0ccd70045ce4d8b4a0d67da760963 - Sigstore transparency entry: 2136102812
- Sigstore integration time:
-
Permalink:
Tbot223/tbot223-base@03175c3a455a5617be4d252f511820ad2b6405fd -
Branch / Tag:
refs/tags/v1.0.0rc2 - Owner: https://github.com/Tbot223
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@03175c3a455a5617be4d252f511820ad2b6405fd -
Trigger Event:
release
-
Statement type:
File details
Details for the file tbot223_base-1.0.0rc2-py3-none-any.whl.
File metadata
- Download URL: tbot223_base-1.0.0rc2-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa80eecb4f300f0a5534111a978a47c899cb6d72130cedfd3d475b0ce23459e8
|
|
| MD5 |
f625fb446a4eb6f6249437f6c4de5b1f
|
|
| BLAKE2b-256 |
18c99da8b9789f59a22f283e455d4d9afa629a8b62bfd03699d2477854e7b0a2
|
Provenance
The following attestation bundles were made for tbot223_base-1.0.0rc2-py3-none-any.whl:
Publisher:
publish.yml on Tbot223/tbot223-base
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tbot223_base-1.0.0rc2-py3-none-any.whl -
Subject digest:
fa80eecb4f300f0a5534111a978a47c899cb6d72130cedfd3d475b0ce23459e8 - Sigstore transparency entry: 2136102867
- Sigstore integration time:
-
Permalink:
Tbot223/tbot223-base@03175c3a455a5617be4d252f511820ad2b6405fd -
Branch / Tag:
refs/tags/v1.0.0rc2 - Owner: https://github.com/Tbot223
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@03175c3a455a5617be4d252f511820ad2b6405fd -
Trigger Event:
release
-
Statement type: