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

Now, you have a command_handler decorator that can be used an be filled out an application registry with the decorated method.

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

handle_stuff is unmodified by its decorator and is purely unit testable. No overhead.

Difference from Venusian

  • Tamahagane supports absolute and relative name of module on scanner method scan.
  • Tamahagane does not have a onerror on the scan method, it raises.
  • Tamahagane does not have a category on the scan method, the categories are the attributes of the registry, nothing less, nothing more.
  • Tamahagane does not support class decoration.

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 0.4.3

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 0.4.3
File Size Uploaded
tamahagane-0.4.3.tar.gz 6.4 kB Details

Built distribution (wheel)

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

Total release size: 13.7 kB

Release files / tamahagane-0.4.3.tar.gz

Download URL tamahagane-0.4.3.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dce82d77564f24e47c9717ff136247508b11c46c1679d2e9e46ee3197ba7273b
BLAKE2b-256 checksum
How to use checksums
e06acc6d81ddb0378add194b6047feaad917be53bc71237de60cd3ad3277052b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.6 CPython/3.12.12 Linux/6.11.0-1018-azure

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

Download URL tamahagane-0.4.3-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8b3ff8b61cc304bd78c1d16461c64bb678b629198a99244609b6a0c8016779b
BLAKE2b-256 checksum
How to use checksums
a72bfb284c2a11050c2a31040c7d8535496ccccc6c90dfb6483f84fc6506ca7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.6 CPython/3.12.12 Linux/6.11.0-1018-azure

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.0.0

2 release files

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