Azure / Azure/azure-functions-durable-python

Wrong return type on create_timer()

Aperta Adatta ai principianti
#587 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
bug Debuggability fixed-in-v2 P2
Lingua principale
Python
Stelle
157
Fork
70
Merge medio
2g 10h
PR unite (30g)
2

Descrizione

🐛 **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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start at azure/durable_functions/models/DurableOrchestrationContext.py around line 601 and inspect the return annotation for create_timer(). Reproduce the example with Pylance, then verify that calling cancel() no longer produces a type-checking error and that the annotation accurately represents the returned timer task.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
72/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.