Metadata-Version: 2.4
Name: extra-type-helpers
Version: 0.8.1
Author: George Ogden
License: MIT License
        
        Copyright (c) 2025 George Ogden
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: <3.15,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typing-extensions; python_version < "3.13"
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.
