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.3.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.3-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for extra_type_helpers-0.8.3.tar.gz
Algorithm Hash digest
SHA256 b3f6a6f1e51da03316571c365d5ce883dbeb5683213c3d2c35c94d94a3169ea4
MD5 5411e6ebfd3dd1369801eb0884bd920d
BLAKE2b-256 50a181d9de9de0ae5570ff616af76531eb931e40790e4e7eae7b78edf9c966f1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for extra_type_helpers-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cf9d19802f71443d44b7020329a32b2c4c62b6d1f054f8d0b569c8ff9a5f648b
MD5 6e3cf042f2d6931afaaf10a3dba90faa
BLAKE2b-256 1f23a7de55f74f6db5eb7838cef18aacfb9f31efaa3b8988b131bf4e59d390f9

See more details on using hashes here.

Provenance

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