Skip to main content

A lightweight collection of typing helpers, aliases, protocols, and foundational type utilities for modern Python applications.

Project description

typal

A lightweight collection of reusable typing utilities for modern Python.

Overview

typal provides small, composable building blocks for Python type annotations.

It avoids type explosion and focuses on clarity, reuse, and native typing features.


Features

  • Optional type helpers (Opt[T])
  • Functional type aliases (Mapper, Predicate, Action)
  • Collection shortcuts (Seq[T], List[T])
  • Common type unions (StrOrInt, PathOrStr, etc.)
  • Enum-aware type utilities
  • Clean separation of typing concerns

Installation

Using uv:

uv add typal

Or pip:

pip install typal

Usage

Optionals

from typal.optionals import Opt

value: Opt[int] = None

Collections

from typal.collections import Seq

def process(items: Seq[str]) -> None:
    ...

Functional types

from typal.functional import Mapper, Predicate, Action

def transform(x: int) -> str:
    return str(x)

m: Mapper[int, str] = transform

Unions

from typal.unions import StrOrInt, PathOrStr

def load(path: PathOrStr) -> StrOrInt:
    ...

Tuples

from typal.tuples import Pair, Triple

Point = Pair[float]
RGB = Triple[int]

Design Philosophy

typal follows these principles:

  • Prefer native Python typing (|, list[T], dict[K, V])
  • Avoid combinatorial type explosion
  • Provide reusable abstractions, not exhaustive aliases
  • Keep the API small, predictable, and composable

Non-goals

typal does NOT aim to:

  • Replace Python's built-in typing system
  • Provide exhaustive pre-generated type variants
  • Introduce framework-specific abstractions
  • Replace domain models

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

typal-0.1.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

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

typal-0.1.0-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file typal-0.1.0.tar.gz.

File metadata

  • Download URL: typal-0.1.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for typal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 84796218549bd95a363d6b0c386256292f91e9ee01be6eb1bf2e7c9e8dc1ed56
MD5 7b3c7f05098e7a2a5cae991601a8ca47
BLAKE2b-256 37ed50c60a0bb12268e2027a8ab4f3ea7a23417cdb8ccec3b43ff2a16e6cd60d

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on agrahub/typal-py

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

File details

Details for the file typal-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: typal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for typal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42c415f6d8971cabbd9240c546869eefdb01d76ade306c9a5dbb36e884d010e0
MD5 6cec9b0037ad948911902229e12d7bb3
BLAKE2b-256 fa9532d80f9e341091493db35fe91ffb93f3ae11d6f511aeb007bb62dc4b6dd3

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on agrahub/typal-py

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