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 git+https://github.com/George-Ogden/extra-types

Slow Install

pip install git+https://github.com/George-Ogden/extra-types

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.0.tar.gz (7.1 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.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: extra_type_helpers-0.8.0.tar.gz
  • Upload date:
  • Size: 7.1 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.0.tar.gz
Algorithm Hash digest
SHA256 e16fef83870a17e9acf32d2a66e7bf03188aa34d908f70e64319cd129e049311
MD5 aab06be16330b3592e8e4e19bc1b705f
BLAKE2b-256 12f3e909dba6636eebbff51bb07c9174ffd069f0b17d7479b10bd1c0bc46ae01

See more details on using hashes here.

Provenance

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

Publisher: release.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for extra_type_helpers-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a1cea58740f113e1277885dd0cbccab6328e3a815dc453b251f9da68120a1db
MD5 6250fe6868c8f5a7b9112114414aa6cc
BLAKE2b-256 1461ffe02cf712fec2c0dabb1235fa8f0666c5938ed15f4df1f73227779371b8

See more details on using hashes here.

Provenance

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

Publisher: release.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