-
Notifications
You must be signed in to change notification settings - Fork 1
/
test1.py
59 lines (42 loc) · 1.39 KB
/
test1.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
from __future__ import annotations
from flywheel.context import CollectContext, InstanceContext
from flywheel.fn.endpoint import FnCollectEndpoint, wrap_endpoint
from flywheel.globals import global_collect, local_collect
from flywheel.overloads import SimpleOverload
from typing_extensions import reveal_type
class greet():
name = SimpleOverload("name")
@classmethod
def call(cls, name: str) -> str:
for selection in cls.collect.select(False):
if not selection.harvest(cls.name, name):
continue
selection.complete()
break
else:
return f"Ordinary, {name}."
return selection(name)
@wrap_endpoint
@classmethod
def collect(cls, *, name: str):
yield cls.name.hold(name)
def shape(name: str) -> str:
...
return shape
@global_collect
@greet.collect(name="Teague")
@greet.collect(name="Grey")
def greet_someone(name: str) -> str:
return "Stargaztor"
reveal_type(greet_someone)
with InstanceContext().scope() as ins, CollectContext().scope() as cs:
ins.instances[str] = "test"
@local_collect
@greet.collect(name="Grey")
def greey_grey(name: str) -> str:
print("1111", greet.call(name))
return "Grey"
print(cs.fn_implements)
#print(greet.call("Teague"))
print(greet.call("Grey"))
#print(greet.call("Hizuki"))