Azure / Azure/azure-functions-durable-python
Wrong return type on create_timer()
- Ngôn ngữ chính
- Python
- Star
- 157
- Fork
- 70
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 2
Mô tả
🐛 **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
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu tại azure/durable_functions/models/DurableOrchestrationContext.py, khoảng dòng 601, và kiểm tra chú thích kiểu trả về của create_timer(). Tái hiện ví dụ bằng Pylance, sau đó xác minh rằng việc gọi cancel() không còn tạo ra lỗi kiểm tra kiểu và chú thích đó biểu diễn chính xác tác vụ hẹn giờ được trả về.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- api
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 72/100