Metadata-Version: 2.4
Name: extra-type-helpers
Version: 0.8.4
Author: George Ogden
Project-URL: Documentation, https://george-ogden.github.io/extra-types/
Project-URL: Homepage, https://github.com/George-Ogden/extra-types/
Project-URL: Issues, https://github.com/George-Ogden/extra-types/issues/
Project-URL: Repository, https://github.com/George-Ogden/extra-types.git
Requires-Python: <3.16,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typing-extensions>=4.16.0; python_full_version < "3.15"
Dynamic: license-file

# 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.

```python
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

```bash
uv pip install extra-type-helpers
```

### Slow Install

```bash
pip install extra-type-helpers
```

## Bugs/Feedback

Use the issue tracker for bugs/feedback, please.
