Skip to main content

Tamahagane

Documentation Continuous Integration Coverage Report

Forge your application registries.

Tamahagane is a library designed for constructing application registries, the essential foundation for building decoupled software architectures and enabling unit testing on application handlers.

Motivation

Tamahagane essentially serves as a modern alternative to Venusian, fulfilling the same core functionality.

The decision to create a new library stems from Venusian's limitations: it was originally built for Python 2, relies heavily on dynamic behavior, and lacks type support.

Tamahagane reuse the same vocabular, a Scanner and an attach function, but the API is not fully compatible, in order to get a simpler version.

Usage

To use Tamahagane you need to create a registries class that hold all registries your app may load. The definition of the registry is free and depends of the usage.

from dataclasses import dataclass

@dataclass
class Registries:
    app_registry: ...

After what, the registries is filled out using the scan of the application code.

import tamahagane as th

scanner = th.Scanner[Registries](Registries(app_registry=...))
scanner.scan("app.service_handlers")

At this time, the app.service_handlers is a module, or a package containing submodules, that will be recursibely loaded. It contains decorated function, where the decorator has been created in the application code to create the callback.

from collections.abc import Callable
from typing import Any

import tamahagane as th


CommandHandler = Callable[..., Any]

def command_handler(wrapped: CommandHandler) -> CommandHandler:

    def callback(registries: Registries) -> None:
        registries.app_registry.do_something_with(wrapped, ...)

    th.attach(wrapped, callback, category="app_registry")
    return wrapped

You now have a command_handler decorator that can be applied to functions, which will register them in the application registry.

@command_handler
def handle_stuff(...):
    ...

The original handle_stuff function remains unchanged by the decorator, making it fully unit-testable with no added overhead.

Tamahagane differs from Venusian in its callback method design.
Rather than receiving the scanner as a parameter, the callback is provided with the
registries object, which is shared across all scanned decorators.

This design choice ensures type safety and better integration with modern Python
practices.

Additionally, the callback must be defined within the decorator itself to ensure access
to the wrapped method.
This eliminates unnecessary parameters and maintains a consistent, localized scope for
the callback logic.

Difference from Venusian

  • Tamahagene is fully typed.
  • Tamahagane supports absolute and relative name of module on scanner method scan.
  • Tamahagane ignore does not accept a callable method.
  • Tamahagane does not have a onerror on the scan method, it raises.
  • Tamahagane does not have a category on the scan method, categories are declared as attributes of the registry, nothing less, nothing more.
  • Tamagane does not support class/method decorator, does not provide lift decorators.

Installation

Tamahagane is available on PyPI

So you can installing using your favorite packaging tool, mine is uv:

uv add tamahagane

List of libraries using Tamahagane

Here is a curative list of projects using tamahagane:

Library Description Repository
fastlife A web framework that register routes, templates and more using th. github.com/mardiros/fastlife
messagebus A message bus implementation for Python applications. github.com/mardiros/messagebus
whitesmith A testing library for blacksmith rest client. It scan routes, like a read web framework. github.com/mardiros/whitesmith

See also

Metadata

Release files for tamahagane 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tamahagane 1.0.1
File Size Uploaded Provenance Actions
tamahagane-1.0.1.tar.gz 6.7 kB Without provenance Details for tamahagane-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tamahagane 1.0.1
File Interpreter ABI Platform Actions
tamahagane-1.0.1-py3-none-any.whl Python 3 none any Details for tamahagane-1.0.1-py3-none-any.whl

Total release size: 14.4 kB

Release files / tamahagane-1.0.1.tar.gz

Download URL tamahagane-1.0.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8a3661731afc0385ad2172595a0142abee8d45279b3a9c9430edb5e33a637b7a
BLAKE2b-256 checksum
How to use checksums
3f70fe66cfe68c6b46ce7796f7a51b06aa7127dc394d06bec6857bbc19b875c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.7 CPython/3.12.16 Linux/7.0.0-1017-azure

Release files / tamahagane-1.0.1-py3-none-any.whl

Download URL tamahagane-1.0.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27f3746136ca45ebcbc4372cd4a692f8d136106cd74aabd9c24df96ba94bfe81
BLAKE2b-256 checksum
How to use checksums
6856047a363d5ef3b7f9f378e790a21b9ab29e9450a79d66e1b3ba11eb350c96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.7 CPython/3.12.16 Linux/7.0.0-1017-azure

Security for tamahagane 1.0.1

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page