Skip to main content

Base result and exception tracking utilities for Python.

Project description

한국어 (Korean)

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:

  • Result and ResultStatus for explicit success, failure, and cancelled outcomes.
  • ExceptionTracker for 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 Result implementation.
  • 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:

Repository maintenance docs:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tbot223_base-1.0.0rc2.tar.gz (91.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tbot223_base-1.0.0rc2-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

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

Hashes for tbot223_base-1.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 0522da3f0df66e8e1c2c4c618d104d406be0ccd70045ce4d8b4a0d67da760963
MD5 ef1606d85c98431f89b4fc214aed495a
BLAKE2b-256 6a7ceef4c8b5d6ff2c21792129e47c35128cae8e3c92a5088d48adc4406f713a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tbot223_base-1.0.0rc2.tar.gz:

Publisher: publish.yml on Tbot223/tbot223-base

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for tbot223_base-1.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 fa80eecb4f300f0a5534111a978a47c899cb6d72130cedfd3d475b0ce23459e8
MD5 f625fb446a4eb6f6249437f6c4de5b1f
BLAKE2b-256 18c99da8b9789f59a22f283e455d4d9afa629a8b62bfd03699d2477854e7b0a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tbot223_base-1.0.0rc2-py3-none-any.whl:

Publisher: publish.yml on Tbot223/tbot223-base

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page