Metadata-Version: 2.1
Name: slightly-better-types
Version: 0.0.1
Summary: Improved abstraction for dealing with union and named types.
Home-page: https://github.com/slightly-better-python/slightly-better-types
Author: Peter Wensel
Author-email: pwensel@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE

# slightly-better-types

... arguably

Improved abstraction for dealing with union and named types.

## Installation

```bash
pip install slightly-better-types==0.0.1
```

## Usage

Using the `Function` class:

```python
from slightly_better_types.function import Function


def accepts_string(a: str, b: int):
    pass


sb_function = Function(accepts_string)

sb_function.accepts('string', 1)  # True
sb_function.accepts(1, 'string')  # False
sb_function.accepts('string')  # False
```

Using `Handlers` to determine which methods accept a given set of input:

```python
from slightly_better_types.handlers import Handlers


class Bar:
    def accepts_string(self, a: str):
        pass

    def accepts_string_too(self, a: str):
        pass

    def accepts_int(self, a: int):
        pass


handlers = Handlers(Bar)
list(handlers.accepts('a string').all().keys())  # ['accepts_string', 'accepts_string_too']
list(handlers.accepts(1).first().get_name())  # 'accepts_int'
```

## Tests

```bash
python3 -m unittest
```

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.


