Skip to main content

Python strong typing suite, along with Typed NumPy: Static shape typing and runtime shape validation.

Project description

typingkit

Ruff

Python strong typing suite, along with Typed NumPy: Static shape typing and runtime shape validation.

[!WARNING] Experimental & WIP. See USAGE.md for more details.

Installation

Install uv (optional, recommended)

Install uv, if not already. Check here for installation instructions.

It is recommended to use uv, as it will automatically install the dependencies in a virtual environment. If you don't want to use uv, skip to the next step.

TL;DR: Just run

curl -LsSf https://astral.sh/uv/install.sh | sh
Install the package

The dependencies are listed in the pyproject.toml file. At present, the only required dependency is numpy.

Install the package from the PyPI release:

# Using uv
uv add typingkit

# Or with pip
pip3 install typingkit

To install from the latest commit:

uv add git+https://github.com/AshrithSagar/typingkit.git@main

Usage

from typing import TypeVar

from typingkit._typed.ndarray import TypedNDArray

# Shape variables are just regular TypeVar's
N = TypeVar("N", bound=int, default=int)
M = TypeVar("M", bound=int, default=int)

# Create aliases such as these, or use TypedNDArray directly
Vector = TypedNDArray[tuple[N]]
Matrix = TypedNDArray[tuple[M, N]]

v1 = Vector([1, 2, 3])  # Passes
v2 = Vector([4, 5, 6, 7])  # Also passes

v3 = TypedNDArray[tuple[int]]([[8, 9]])
# Fails, since expected 1D array but passed in a 2D array

See USAGE.md for more details.

License

This project falls 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

typingkit-0.2.6.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

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

typingkit-0.2.6-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file typingkit-0.2.6.tar.gz.

File metadata

  • Download URL: typingkit-0.2.6.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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}

File hashes

Hashes for typingkit-0.2.6.tar.gz
Algorithm Hash digest
SHA256 2ca9b11bb24533ee98e88e50b5ba854cde8d9daf59914580785e67b34c535466
MD5 7e7aae64f9248df25632d13cb60363a1
BLAKE2b-256 3a6633721d709b29a08572a9e35fc48c50eb795cc3ec4f9b165ee224df6ce183

See more details on using hashes here.

File details

Details for the file typingkit-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: typingkit-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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}

File hashes

Hashes for typingkit-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2ca241356f0ef01fb5113becc20fd2f1f66f5dfcd5a01cb3e59f316dca19c0eb
MD5 1b09d44217972c57eddb9fe55550a5ef
BLAKE2b-256 7a032c6270ce0d85afc2fc1fa5b0ae8318b057a9b40e5ee04a5fb19b91e4309a

See more details on using hashes here.

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