diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2021-09-05 23:42:05 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2021-09-06 01:39:07 +0300 |
commit | 148b29270eb8fa0974f29be4d85a0ee03b848d1a (patch) | |
tree | 4d874a4bb230151eedaed19ddf14af0ec0e7c060 /src/apscheduler/schedulers | |
parent | 2a685fe105b6c715c16912109dfc0f982e0acd5c (diff) | |
download | apscheduler-148b29270eb8fa0974f29be4d85a0ee03b848d1a.tar.gz |
Migrated annotations to the py3.10 style
Using "from __future__ import annotations" we can do this even on Python 3.7.
Diffstat (limited to 'src/apscheduler/schedulers')
-rw-r--r-- | src/apscheduler/schedulers/async_.py | 11 | ||||
-rw-r--r-- | src/apscheduler/schedulers/sync.py | 6 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/apscheduler/schedulers/async_.py b/src/apscheduler/schedulers/async_.py index 010b3ce..abbe257 100644 --- a/src/apscheduler/schedulers/async_.py +++ b/src/apscheduler/schedulers/async_.py @@ -5,7 +5,7 @@ import platform from contextlib import AsyncExitStack from datetime import datetime, timedelta, timezone from logging import Logger, getLogger -from typing import Any, Callable, Iterable, Mapping, Optional, Type, Union +from typing import Any, Callable, Iterable, Mapping, Optional, Type from uuid import uuid4 import anyio @@ -34,7 +34,7 @@ class AsyncScheduler(EventSource): _worker: Optional[AsyncWorker] = None _task_group: Optional[TaskGroup] = None - def __init__(self, data_store: Union[DataStore, AsyncDataStore] = None, *, + def __init__(self, data_store: DataStore | AsyncDataStore | None = None, *, identity: Optional[str] = None, logger: Optional[Logger] = None, start_worker: bool = True): self.identity = identity or f'{platform.node()}-{os.getpid()}-{id(self)}' @@ -94,7 +94,7 @@ class AsyncScheduler(EventSource): def unsubscribe(self, token: SubscriptionToken) -> None: self._events.unsubscribe(token) - # def _get_taskdef(self, func_or_id: Union[str, Callable]) -> Task: + # def _get_taskdef(self, func_or_id: str | Callable) -> Task: # task_id = func_or_id if isinstance(func_or_id, str) else callable_to_ref(func_or_id) # taskdef = self._tasks.get(task_id) # if not taskdef: @@ -114,11 +114,10 @@ class AsyncScheduler(EventSource): # pass async def add_schedule( - self, func_or_task_id: Union[str, Callable], trigger: Trigger, *, id: Optional[str] = None, + self, func_or_task_id: str | Callable, trigger: Trigger, *, id: Optional[str] = None, args: Optional[Iterable] = None, kwargs: Optional[Mapping[str, Any]] = None, coalesce: CoalescePolicy = CoalescePolicy.latest, - misfire_grace_time: Union[float, timedelta, None] = None, - tags: Optional[Iterable[str]] = None, + misfire_grace_time: float | timedelta | None = None, tags: Optional[Iterable[str]] = None, conflict_policy: ConflictPolicy = ConflictPolicy.do_nothing ) -> str: id = id or str(uuid4()) diff --git a/src/apscheduler/schedulers/sync.py b/src/apscheduler/schedulers/sync.py index b80210d..487b724 100644 --- a/src/apscheduler/schedulers/sync.py +++ b/src/apscheduler/schedulers/sync.py @@ -7,7 +7,7 @@ from concurrent.futures import FIRST_COMPLETED, Future, ThreadPoolExecutor, wait from contextlib import ExitStack from datetime import datetime, timedelta, timezone from logging import Logger, getLogger -from typing import Any, Callable, Iterable, Mapping, Optional, Type, Union +from typing import Any, Callable, Iterable, Mapping, Optional, Type from uuid import uuid4 from ..abc import DataStore, EventSource, Trigger @@ -96,10 +96,10 @@ class Scheduler(EventSource): self._events.unsubscribe(token) def add_schedule( - self, func_or_task_id: Union[str, Callable], trigger: Trigger, *, id: Optional[str] = None, + self, func_or_task_id: str | Callable, trigger: Trigger, *, id: Optional[str] = None, args: Optional[Iterable] = None, kwargs: Optional[Mapping[str, Any]] = None, coalesce: CoalescePolicy = CoalescePolicy.latest, - misfire_grace_time: Union[float, timedelta, None] = None, + misfire_grace_time: float | timedelta | None = None, tags: Optional[Iterable[str]] = None, conflict_policy: ConflictPolicy = ConflictPolicy.do_nothing ) -> str: |