-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
60 lines (41 loc) · 809 Bytes
/
test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from attempt.things import struct, gathers
UserInfo = struct(
("name", "string"),
("age", "integer"),
("city", "string?"),
)
u1 = UserInfo() # error
u2 = UserInfo( # ok
name="Bob",
age=42,
city="St. Petersburg",
)
u3 = UserInfo( # ok
name="Bob",
age=42,
city=None,
)
u4 = UserInfo( # error
name="Bob",
age=42,
)
u4 = UserInfo( # error
name="Charlie",
age="old",
city=None
)
def f(u: UserInfo):
reveal_type(u.name)
reveal_type(u.city)
###
from typing import Awaitable
@gathers
def my_gather(*args) -> Awaitable:
assert False
async def foo() -> int:
return 42
async def bar() -> str:
return "hey"
async def main() -> None:
x = await my_gather(foo(), bar(), bar())
reveal_type(x) # tuple[int, str, str]