Skip to content

Releases: ArcletProject/Letoderea

Letoderea 0.19.0

30 Aug 13:55

Choose a tag to compare

破坏性改动

  • 取消 Python 3.9 版本的支持
  • Resultale 协议由 __result_type__: type[T] 改为 def check_result(self, value) -> Result[T] | None: ...

新增

  • waterfall 方法,其可以遍历传入的每一个 subscriber 并迭代结果 (仍然尊重 BLOCK)
  • Publisher 增加 check_subscriber 方法,允许发布者在订阅者订阅时对其进行检查或其他操作,
  • post 方法 增加参数 validate 以决定是否对返回的值进行校验
  • ExitState 增加方法 finish,以允许 STOPBLOCK 可以携带执行结果。

Full Changelog: 0.18.0...0.19.0

Letoderea 0.18.0

06 Aug 17:23

Choose a tag to compare

  • 升级 Tarina 0.7.0
  • 重构 StepOut, 利用 propagate 特性替代原来的嵌套 subscriber
  • 支持 step_out 装饰在 Subscriber 上,以复用逻辑且不影响其原来功能
  • global_propagatorscurrent_subscriber, 其中 current_subscriber 是一个 ContexVar
    • defer 函数现在可以省略 ctx 参数了
  • 优化 Provider.validate
  • Scope 增加 enabledisable 方法
  • 修改 derefin 操作为 in_ 函数

Full Changelog: 0.17.0...0.18.0

Letoderea 0.17.0

19 Apr 09:13

Choose a tag to compare

  • 新的模块 collect, 根据函数的签名来构造事件体类型
  • make_event 经过了 dataclass_tranform, 不需要装饰事件时额外再写一个 dataclass
  • EventSystem 类的方法被拆分,仅保留一个内部类来存放变量
  • 新的定义 gather 方式: @gather 装饰器,也即可以为完全无关的类型设置 gather
  • enter_if, bypass_if 等可以链式组合
  • Depnd 的缓存现在是全局性的
  • 支持监听器为生成器
  • 默认在 Contexts 中包含一个 AsyncExitStack

Full Changelog: 0.16.0...0.17.0

Letoderea 0.16.0

20 Feb 08:28

Choose a tag to compare

What's Changed

Full Changelog: 0.13.0...0.16.0

Letoderea 0.13.0

08 Dec 03:48

Choose a tag to compare

Letoderea 0.6.0

27 May 06:53

Choose a tag to compare

  1. 订阅者函数的参数类型现在支持使用 Annotated 来便捷注入 provider:
    async def _(
        a: int,  # Need Provider
        b: Annotated[str, "index"],  # will generate provider which fetch "index" from ctx
        c: Annotated[float, lambda ctx: ctx["foo"]]  # will generate provider which fetch "foo" from ctx
    ): ...
  2. 增加 bypass_if 便捷装饰器, 用来注入一条件判断的辅助器:
    from arclet.letoderea import bypass_if
    ....
    @bypass_if(lambda ctx: not isinstance(ctx["event"], A))  # subscriber will pass when event is not A
    async def _(): ...
  3. 增加 deref 函数, 用来生成获取事件属性,或比较事件属性是否符号条件的 predicate, 并给如 bypass_if , Annotated , provide 使用
    from arclet.letoderea.ref import deref, generate
    ...
    @dataclass
    class A:
        text: str
    
    print(deref(A).text)  # {'text': None}
    print(deref(A).text == "123")  # {'text': <function Deref.__eq__.<locals>.<lambda>>}
    print(
        generate(deref(A).text == "123")(  # True
            {"event": A(text="123")}
        )
    )
  4. 增加 make_event 装饰器, 用来自动注入 gather 方法
  5. 依赖注入可以根据参数名直接从事件中尝试获取对应参数
  6. Publisher.publish 现在不经过事件系统,直接分发给自身的订阅者
  7. depend_handler 的第二个参数现在可以接受已存在的 contexts

Letoderea 0.5.0

23 Apr 14:12

Choose a tag to compare

  1. es.register -> es.on
  2. StepOut 增加泛型支持
  3. StepOut 支持 async iter, 使用方式如下:
async for res in StepOut([Event], handler):
   ...

等价于

while True:
    res = await break_point(StepOut([Event], handler))
    ...
  1. 事件发布时,全局 publisher 现在总是会加入待检查队列中

Full Changelog: v0.4.1...0.5.0

Letoderea 0.4.0

23 Mar 06:10

Choose a tag to compare

What's Changed

  • 重构了整个 Letoderea。现今的依赖注入基于静态编译后的 Provider + 动态的类型推断
  • 引入 Provider,并在 Subscriber 注册时确定每个参数可分配的 Provider。当事件传递时每个参数上的 Provider 将依次执行。
  • 重做 Auxiliary,并引入 Combine 机制,即允许多个 Auxiliary 组合,类似 A -- AND --> B -- AND --> [C or D or E] -- AND --> F
  • 重做 Event, 现在 Event 属于一类协议,仅要求实现一个 async def gather 函数,其接受一个 context: Contexts 参数,负责将事件参数传入 Contexts 中。例:
class ExampleEvent:
    foo: int
    bar: str
    async def gather(self, context: Contexts):
        context["foo"] = self.foo
        context["bar"] = self.bar
  • ProviderEvent 可以 配合使用:
class ExampleProvider(Provider[int]):
    async def __call__(self, context: Contexts):
        return context["foo"]

class ExampleEvent:
    foo: int
    bar: str
    async def gather(self, context: Contexts):
        context["foo"] = self.foo
        context["bar"] = self.bar

    class BarProvider(Provider[str]):
        async def __call__(self, context: Contexts):
            return context["bar"]

Full Changelog: 0.3.0...0.4.0

Letoderea 0.3.0~0.3.3

20 Feb 03:29

Choose a tag to compare

1.结构更改, publisher仅作为存储delegate的容器, 下一步预计进一步弱化其作用
2. condition与decorator合并为auxiliary, 并增加两类生命周期
3. 让event数据变得更"合理“

Letoderea 0.2.7

10 Feb 09:49

Choose a tag to compare

1.加入Depend, 即依赖注入
2.修改parser_handler逻辑,使其支持:

  • 以None为默认值的参数(必须是在anno后面注明了为None), 如(test: str = None)
  • 仅以类型注解来分配参数(不推荐)