Skip to content

Commit

Permalink
Added add_periodic_callback coroutine typing
Browse files Browse the repository at this point in the history
The `add_periodic_callback` method only had the `Callable` type hint while it also supports asyncio functions. This adds that type hint so `pyright` won't complain anymore :)
  • Loading branch information
wolph committed Jul 24, 2022
1 parent ff39f02 commit 69e2992
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions panel/io/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from functools import partial
from typing import (
TYPE_CHECKING, Any, Callable, ClassVar, Dict, Iterator as TIterator, List,
Optional, Tuple, Union,
Optional, Tuple, Union, Coroutine,
)
from urllib.parse import urljoin
from weakref import WeakKeyDictionary
Expand Down Expand Up @@ -379,8 +379,9 @@ def as_cached(self, key: str, fn: Callable[[], None], ttl: int = None, **kwargs)
return ret

def add_periodic_callback(
self, callback: Callable[[], None], period: int=500,
count: Optional[int] = None, timeout: int = None, start: bool=True
self, callback: Callable[[], None] | Coroutine[Any, Any, None],
period: int=500, count: Optional[int] = None, timeout: int = None,
start: bool=True
) -> PeriodicCallback:
"""
Schedules a periodic callback to be run at an interval set by
Expand Down

0 comments on commit 69e2992

Please sign in to comment.