Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flextype-0.1.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flextype-0.1.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

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

Hashes for flextype-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3378a7f4d5b8c8c75d6e1e5d05efea47394df0769060d836138c7634f9d3ee8c
MD5 46bbb62f1424e2221abd195031992bb2
BLAKE2b-256 56a1bc5afd8d5886cfbcef4ac8356d01e9eaf5ae6da9a2d3c0c70dd0d0cc6f99

See more details on using hashes here.

Provenance

The following attestation bundles were made for flextype-0.1.0.tar.gz:

Publisher: publish-release.yml on Cortys/flextype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for flextype-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fcb20ce05d7e918cb1faf6db0963233a7280068dacfe1b6a681ee487ee22675
MD5 ca24a8c3492e8d149c959109a5d04876
BLAKE2b-256 12f0c5d324d557acbef0a1c0224adb09fd39d5caa75518f2705eb8d7e5168ceb

See more details on using hashes here.

Provenance

The following attestation bundles were made for flextype-0.1.0-py3-none-any.whl:

Publisher: publish-release.yml on Cortys/flextype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page