Azure / Azure/azure-functions-durable-python
Wrong return type on create_timer()
- 主要语言
- Python
- 星标
- 157
- 派生
- 70
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 2
描述
🐛 **Describe the bug**
Type hint for return value of `create_timer()` is `TaskBase`, but that does not contain the `cancel()` function. ~Returning `TimerTask` seems more appropiate.~
_Edit: See comment below on why `TimerTask` might not be a viable type anyway_
Current source:
https://github.com/Azure/azure-functions-durable-python/blob/4ab004b6bc994b0395ee965186f8402b86b7a887/azure/durable_functions/models/DurableOrchestrationContext.py#L601
Example code:
```python
expiration = context.current_utc_datetime + timedelta(seconds=20)
timeout_task = context.create_timer(expiration)
timeout_task.cancel() # <-- Pylance shows error: "Cannot access attribute "cancel" for class "TaskBase""
```
🤔 **Expected behavior**
You should be able to call `cancel()`without linter/type checker errors.
☕ **Steps to reproduce**
See above
贡献指南
调研方向
从 azure/durable_functions/models/DurableOrchestrationContext.py 约第 601 行开始,检查 create_timer() 的返回注解。使用 Pylance 重现该示例,然后验证调用 cancel() 不再产生类型检查错误,并确认该注解准确表示返回的计时器任务。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 72/100