Skip to content

Wrong return type on create_timer() #587

Description

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

def create_timer(self, fire_at: datetime.datetime) -> TaskBase:

Example code:

    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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebuggabilityExperience problem debugging code.P2Priority 2bugSomething isn't workingfixed-in-v2Fixed in azure-functions-durable 2.x

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions