Azure / Azure/azure-functions-durable-python
Wrong return type on create_timer()
- Lenguaje dominante
- Python
- Estrellas
- 157
- Forks
- 70
- Merge medio
- 2 d 10 h
- PR fusionados (30 d)
- 2
Descripción
🐛 **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
Guía de contribución
Línea de trabajo
Comienza en azure/durable_functions/models/DurableOrchestrationContext.py alrededor de la línea 601 e inspecciona la anotación de retorno de create_timer(). Reproduce el ejemplo con Pylance y, a continuación, verifica que llamar a cancel() ya no produzca un error de comprobación de tipos y que la anotación represente correctamente la tarea de temporizador devuelta.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Tranquilo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 72/100