Lazy and structural helpers for Python dispatch and type checks
Project description
flextype
Lazy and structural helpers for Python dispatch and type checks.
flextype provides lazy alternatives to functools.singledispatch, isinstance,
and issubclass. It supports delayed imports, string-based type references,
runtime registries, and dispatch against dynamically registered structural types.
Install
flextype requires Python 3.13 or newer.
pip install flextype
uv add flextype
Quickstart
from flextype import flexdispatch
@flexdispatch
def describe(value: object) -> str:
return "object"
@describe.register("pathlib.Path")
def describe_path(value: object) -> str:
return f"path-like: {value}"
String registrations are resolved lazily, so optional imports can stay optional until a matching value is dispatched.
Development
uv run --group lint ruff check src/flextype tests/flextype
uv run --group lint ty check
uv run --group test pytest tests/flextype
Pre-commit hooks are managed with prek:
uvx prek install
uvx prek run --all-files
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flextype-0.1.0.tar.gz.
File metadata
- Download URL: flextype-0.1.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3378a7f4d5b8c8c75d6e1e5d05efea47394df0769060d836138c7634f9d3ee8c
|
|
| MD5 |
46bbb62f1424e2221abd195031992bb2
|
|
| BLAKE2b-256 |
56a1bc5afd8d5886cfbcef4ac8356d01e9eaf5ae6da9a2d3c0c70dd0d0cc6f99
|
Provenance
The following attestation bundles were made for flextype-0.1.0.tar.gz:
Publisher:
publish-release.yml on Cortys/flextype
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flextype-0.1.0.tar.gz -
Subject digest:
3378a7f4d5b8c8c75d6e1e5d05efea47394df0769060d836138c7634f9d3ee8c - Sigstore transparency entry: 1978909583
- Sigstore integration time:
-
Permalink:
Cortys/flextype@d997e0d139028b9ac4072f55479d105518dbe530 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/Cortys
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-release.yml@d997e0d139028b9ac4072f55479d105518dbe530 -
Trigger Event:
release
-
Statement type:
File details
Details for the file flextype-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flextype-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fcb20ce05d7e918cb1faf6db0963233a7280068dacfe1b6a681ee487ee22675
|
|
| MD5 |
ca24a8c3492e8d149c959109a5d04876
|
|
| BLAKE2b-256 |
12f0c5d324d557acbef0a1c0224adb09fd39d5caa75518f2705eb8d7e5168ceb
|
Provenance
The following attestation bundles were made for flextype-0.1.0-py3-none-any.whl:
Publisher:
publish-release.yml on Cortys/flextype
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flextype-0.1.0-py3-none-any.whl -
Subject digest:
1fcb20ce05d7e918cb1faf6db0963233a7280068dacfe1b6a681ee487ee22675 - Sigstore transparency entry: 1978909633
- Sigstore integration time:
-
Permalink:
Cortys/flextype@d997e0d139028b9ac4072f55479d105518dbe530 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/Cortys
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-release.yml@d997e0d139028b9ac4072f55479d105518dbe530 -
Trigger Event:
release
-
Statement type: