Skip to main content

No project description provided

Project description

Extra Types

Extra types and type utilities for Python. It provides some useful types that can be easily integrated into your code. Documentation available at https://george-ogden.github.io/extra-types/

Example

PosInt represents positive integers.

from extra_types.types import PosInt

isinstance(0, PosInt) # False
isinstance(1, PosInt) # True
isinstance(2, PosInt) # True
isinstance(1.5, PosInt) # False
isinstance(object(), PosInt) # False


# Use it as a type hint
def setup_agents(num_agents: PosInt) -> None:
    ...

# Validate with attrs
import attrs
@attrs.define
class AgentConfig:
    agent_size: PosInt = attrs.field(validator=attrs.validators.instance_of(PosInt))

# Check with strict cast
from extra_types.type_utils import strict_cast

def generate_positive_integer() -> PosInt:
    number = ...
    return strict_cast(PosInt, number) # raises a TypeError if not a positive integer

Install

Quick Install

uv pip install extra-type-helpers

Slow Install

pip install extra-type-helpers

Bugs/Feedback

Use the issue tracker for bugs/feedback, please.

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

extra_type_helpers-0.8.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

extra_type_helpers-0.8.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file extra_type_helpers-0.8.1.tar.gz.

File metadata

  • Download URL: extra_type_helpers-0.8.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for extra_type_helpers-0.8.1.tar.gz
Algorithm Hash digest
SHA256 92d8e617daac34bd4ee5c0c3fc16e734308e05bb29db6f4761da79bd35c0ba18
MD5 421db99a63b33ae7ae46a8945bdd34f2
BLAKE2b-256 19e33a4d90b7c48d1c8f24f47747baab2f58110386f8de34acfe55c3e33a2f38

See more details on using hashes here.

Provenance

The following attestation bundles were made for extra_type_helpers-0.8.1.tar.gz:

Publisher: pypi-publish.yaml on George-Ogden/extra-types

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

File details

Details for the file extra_type_helpers-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for extra_type_helpers-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bfbacfa58cabae8e544113a527685e93bde33b1280eed1b2c4cb8f5c29ecfa14
MD5 c650160bbfd28144d4b18d3a4d019d4e
BLAKE2b-256 6257cf95d9fa21ffdafc8dd803fb29205eee9b33c79ad3d3d073a111bb553b1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for extra_type_helpers-0.8.1-py3-none-any.whl:

Publisher: pypi-publish.yaml on George-Ogden/extra-types

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