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.2.tar.gz (7.2 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.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: extra_type_helpers-0.8.2.tar.gz
  • Upload date:
  • Size: 7.2 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.2.tar.gz
Algorithm Hash digest
SHA256 5b6a57d435afe325731d642e741b2babbfa79af7d5439358a5b41697f8cda6fb
MD5 605dcded8f5f6120fa383f1609973409
BLAKE2b-256 9127f509dfb2765bdf8bbc60ba1c58a95968d3488b2e9e8b15052094981675ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for extra_type_helpers-0.8.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for extra_type_helpers-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 12a8238748985b08df1d2f823d5cfb5142dac72d52758a1ab4065b243398465c
MD5 9d81eb3510b475c8ff230e6e0a3e32ee
BLAKE2b-256 b76317bf27470c7b26e2ea958aa376708ff100a4067dd87289a914a1d4ea5662

See more details on using hashes here.

Provenance

The following attestation bundles were made for extra_type_helpers-0.8.2-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