-
Notifications
You must be signed in to change notification settings - Fork 42
/
demo.py
37 lines (20 loc) · 876 Bytes
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from argparse import ArgumentParser
from tap import Tap
def add_one(num: int) -> int:
return num + 1
# ----- ArgumentParser -----
parser = ArgumentParser()
parser.add_argument("--rnn", type=str, required=True, help="RNN type")
parser.add_argument("--hidden_size", type=int, default=300, help="Hidden size")
parser.add_argument("--dropout", type=float, default=0.2, help="Dropout probability")
args = parser.parse_args()
print(args.hidden_size) # no autocomplete, no type inference, no source code navigation
add_one(args.rnn) # no static type checking
# ----- Tap -----
class MyTap(Tap):
rnn: str # RNN type
hidden_size: int = 300 # Hidden size
dropout: float = 0.2 # Dropout probability
args = MyTap().parse_args()
print(args.hidden_size) # autocomplete, type inference, source code navigation
add_one(args.rnn) # static type checking