Skip to main content

Nightjar

PyPI version PyPI - Downloads PyPI - Python Version GitHub

A config dispatch library. Supports dataclasses, Pydantic models, and custom converters.

Install

uv add nightjar

Usage

from dataclasses import dataclass
from nightjar import dispatch, register


@dataclass
class StorageConfig:
    pass


@dataclass
class LocalConfig(StorageConfig):
    kind: str = "local"
    path: str = "."


@dataclass
class MemoryConfig(StorageConfig):
    kind: str = "memory"
    capacity: int = 100


@register(kind="local")
@dataclass
class LocalStorage:
    config: LocalConfig


@register(kind="memory")
@dataclass
class MemoryStorage:
    config: MemoryConfig


storage = dispatch(StorageConfig, {"kind": "memory", "capacity": "20"})
assert isinstance(storage, MemoryStorage)
assert storage.config.capacity == 20

local = dispatch(StorageConfig, {"kind": "local", "path": "./data"})
assert isinstance(local, LocalStorage)

The caller supplies StorageConfig; kind selects the implementation. @register infers each concrete config type from its annotation.

Compatibility

  • Python 3.9+: use from __future__ import annotations for A | B annotations on 3.9.
  • Pydantic v1.10 and v2 are supported without an exact version pin. Conversion behavior follows the installed version; uv resolves a compatible release.

Preview the documentation with uv run --group docs mkdocs serve.

Documentation · AI agent guide · Issues · MIT License

Metadata

Release files for nightjar 0.1.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 nightjar 0.1.1
File Size Uploaded
nightjar-0.1.1.tar.gz 93.0 kB Details

Built distribution (wheel)

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

Total release size: 108.8 kB

Release files / nightjar-0.1.1.tar.gz

Download URL nightjar-0.1.1.tar.gz
Size 93.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8eb7df5455850fd22a051daf62dcd00d1407b9b5971866ebed2b0cf31ebd6588
BLAKE2b-256 checksum
How to use checksums
8b145d251f63bbfa59fb3e1dc74a035ed240992415a7533b97a375685c0e4ba6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / nightjar-0.1.1-py3-none-any.whl

Download URL nightjar-0.1.1-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
792595558f8810c801ec62dd49b6f7fad1c1c172731def2b79246e883a52786b
BLAKE2b-256 checksum
How to use checksums
da59ab5a0f13f2194ace92b23da0eef5c3d5ef76587c78aab2f616fc0daa5627
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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