This release is a pre-release and may not be stable for production use.
Swarmauri Typing
swarmauri_typing provides typing utilities for Swarmauri's dynamic component model. It exposes annotated intersection and union helpers used by swarmauri_base to build Pydantic-compatible component unions from runtime registries.
Why Swarmauri Typing?
swarmauri_typing isolates the small dynamic typing helpers used by Swarmauri's component model. It lets foundational packages generate metadata-rich Annotated unions without coupling those helpers to a specific component family.
FAQ
Q: What does UnionFactory do?
A: UnionFactory builds an Annotated[Union[...], ...] type from a caller-provided lookup function. swarmauri_base uses this pattern for dynamic component subtype unions.
Q: What does Intersection do?
A: Intersection computes common classes from input types and returns an annotated type that carries IntersectionMetadata.
Q: Do most application developers import this package directly?
A: Usually no. Most users get this behavior through swarmauri_base.DynamicBase and SubclassUnion.
Features
Intersectioncreates an annotated union of common classes from multiple input types.IntersectionMetadatapreserves the source classes used to build the intersection annotation.UnionFactorybuilds annotated union types from a user-supplied type lookup function.UnionFactoryMetadatarecords the source model or key used to build a dynamic union.- Annotation extenders allow callers to attach additional metadata such as Pydantic discriminators.
- Python 3.10, 3.11, 3.12, 3.13, and 3.14 support.
Installation
Install with uv:
uv add swarmauri_typing
Install with pip:
pip install swarmauri_typing
Usage
Create an intersection annotation:
from typing import get_args
from swarmauri_typing import Intersection, IntersectionMetadata
class Root:
pass
class Left(Root):
pass
class Right(Root):
pass
Common = Intersection[Left, Right]
metadata = [item for item in get_args(Common)[1:] if isinstance(item, IntersectionMetadata)]
assert metadata[0].classes == (Left, Right)
Create a dynamic annotated union:
from typing import Any
from swarmauri_typing import UnionFactory, UnionFactoryMetadata
class JsonStore:
pass
class SqlStore:
pass
def store_types(model_name: str) -> list[type]:
if model_name == "Store":
return [JsonStore, SqlStore]
return []
StoreUnion = UnionFactory(store_types, name="store_union")["Store"]
assert any(
isinstance(item, UnionFactoryMetadata) and item.name == "store_union"
for item in getattr(StoreUnion, "__metadata__", ())
)
Swarmauri Component Usage
swarmauri_base.DynamicBase uses UnionFactory to turn registered component subtypes into discriminated unions. This lets models typed with SubclassUnion[BaseComponent] hydrate concrete subclasses from serialized payloads that include a type field.
from pydantic import Field
from swarmauri_typing import UnionFactory
def component_types(model_name: str) -> list[type]:
return []
SubclassUnion = UnionFactory(
component_types,
name="subclass_union",
annotation_extenders=[Field(discriminator="type")],
)
Related Packages
Foundational packages:
- swarmauri_base uses these typing helpers for dynamic component deserialization.
- swarmauri_core provides the interface contracts for Swarmauri component families.
- swarmauri provides the namespace importer and plugin discovery layer.
- swarmauri_standard provides first-party components that depend on the core/base typing model.
Component-kind packages that benefit from dynamic typing:
- swarmauri_signing_ed25519
- swarmauri_crypto_composite
- swarmauri_keyprovider_inmemory
- swarmauri_storage_memory
- swarmauri_transport_stdio
When To Use This Package
Use swarmauri_typing directly when you need dynamic Annotated type construction in a Swarmauri-compatible package. Most application developers interact with it indirectly through swarmauri_base.ComponentBase, DynamicBase, and SubclassUnion.
License
Apache-2.0
Contributing
When changing these helpers, keep the API small and compatible with Pydantic metadata usage in swarmauri_base, add focused tests for generated annotations, and follow the Swarmauri SDK contribution guide.
Metadata
Release files for swarmauri_typing 0.11.0.dev4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swarmauri_typing-0.11.0.dev4.tar.gz | 9.3 kB | Without provenance | Details for swarmauri_typing-0.11.0.dev4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarmauri_typing-0.11.0.dev4-py3-none-any.whl | Python 3 | none | any | Details for swarmauri_typing-0.11.0.dev4-py3-none-any.whl |
Total release size: 19.6 kB
Release files / swarmauri_typing-0.11.0.dev4.tar.gz
| Download URL | swarmauri_typing-0.11.0.dev4.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbc8eaa1e932b910a8e26326f6b881d4ec6accc331517b770586cef70d640486
|
|
BLAKE2b-256 checksum How to use checksums |
3058622c9a30076ca3c25a218f56aec2610e6507804c2070427b3ef9d8f12289
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / swarmauri_typing-0.11.0.dev4-py3-none-any.whl
| Download URL | swarmauri_typing-0.11.0.dev4-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1662bf10875e1cfbdb7039f389821c704122b10916f6a7616a372632ca44d5e3
|
|
BLAKE2b-256 checksum How to use checksums |
de2468611296d1c18a287888535eb2c3cc1f99d74b311f13e27cfde73a6a53f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for swarmauri_typing 0.11.0.dev4
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.