Skip to main content

Type hints for python 2.x

Project description

# Takayi
Type hints for python 2.X.

`takayi` means `high` in japanese.

## Usage

```python
from takayi.parser import Parser, typehints

parser = Parser()

# ==================================================
@typehints(parser)
def get_sum(x, y):
# type: (int, int) -> int
return x + y

_sum = get_sum(1, 2) # result should be 3

# takayi.exc.ParameterTypeError: Expect => [<type 'int'>, <type 'int'>], Actually => [<type 'int'>, <type 'str'>]
_err_sum = get_sum(1, 'hello')


# ==================================================
@typehints(parser)
def test(x, y=1):
# type: (int, y: int) -> int
return x + y

assert test(1, y=10) == 11


# ==================================================
class Node(object): pass

node = Node()


@typehints(parser, attach_cls=Node)
def get_node():
# type: () -> Node
return node
```

## TODO

- [x] Support kwargs type check
- [ ] More types. FYI: [pep484](https://www.python.org/dev/peps/pep-0484/)

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

takayi-0.3.3.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

takayi-0.3.3-py2-none-any.whl (7.5 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page