We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nakuru-project/nakuru/application.py
Lines 147 to 180 in 9f790eb
executor 中会检查 监听器函数的每个参数的类型定义是否与固有的类型相同,这在一般情况下时可以正常运行的:
# 测试代码 from nakuru import ( CQHTTP, GroupMessage, ) from nakuru.entities.components import Plain app = CQHTTP( host="127.0.0.1", port=8082, http_port=5701, token="" # 可选,如果配置了 Access-Token ) @app.receiver("GroupMessage") async def _(app: CQHTTP, source: GroupMessage): # 通过消息链处理 chain = source.message await app.sendGroupMessage(source.group_id, [ Plain(text="你好"), ]) app.run()
此情况下 annotation 是类型注解的class 对象,可以通过171行的检查。
from __future__ import annotations
为了避免写类型注解时的循环引用,在测试代码最前方加上from __future__ import annotations后,每个参数的 annotation 会变成 str 类型:
此时, executor 方法在 171 行就无法校验通过,而在176行抛出异常抛弃此处事件的处理。但 这种情况下的 监听器函数都是可以正常被调用的。
对 listener 函数的校验更加宽松。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
nakuru-project/nakuru/application.py
Lines 147 to 180 in 9f790eb
executor 中会检查 监听器函数的每个参数的类型定义是否与固有的类型相同,这在一般情况下时可以正常运行的:
此情况下 annotation 是类型注解的class 对象,可以通过171行的检查。
添加
from __future__ import annotations
后为了避免写类型注解时的循环引用,在测试代码最前方加上
from __future__ import annotations
后,每个参数的 annotation 会变成 str 类型:此时, executor 方法在 171 行就无法校验通过,而在176行抛出异常抛弃此处事件的处理。但 这种情况下的 监听器函数都是可以正常被调用的。
建议
对 listener 函数的校验更加宽松。
The text was updated successfully, but these errors were encountered: