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/)
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
Release history Release notifications | RSS feed
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 details)
Built Distribution
File details
Details for the file takayi-0.3.3.tar.gz
.
File metadata
- Download URL: takayi-0.3.3.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 962f840929a64461801b1201d3f8a4654a064adda6937e5853cab9e945114dda |
|
MD5 | 123183496f88e4c7b7f089a47e36a298 |
|
BLAKE2b-256 | 618d552c797dc30ccbf94714e1e46b3bfd60037ba0628da76551319e395881e9 |
File details
Details for the file takayi-0.3.3-py2-none-any.whl
.
File metadata
- Download URL: takayi-0.3.3-py2-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69c0318b81f1efc223844bf49b10a28f8b7b65103e69229466cfc2e0925a6225 |
|
MD5 | 45f54eb3cba0608cb44ec906e8e8c0ea |
|
BLAKE2b-256 | 9c283c0f8a92e60c430b3c00f163cbe3fee502bf3739bc5ea9bcb42a5381707e |