run lint with pyupgrade at py39-plus

This commit is contained in:
pacrob
2025-01-25 15:31:51 -07:00
committed by Paul Robinson
parent 20580b9a4e
commit 8787613e91
44 changed files with 221 additions and 240 deletions

View File

@ -4,11 +4,12 @@ from abc import (
ABC,
abstractmethod,
)
from collections.abc import (
Hashable,
)
from typing import (
Any,
Hashable,
Optional,
Set,
)
import trio_typing
@ -45,7 +46,7 @@ class TaskAPI(Hashable):
class TaskWithChildrenAPI(TaskAPI):
children: Set[TaskAPI]
children: set[TaskAPI]
@abstractmethod
def add_child(self, child: TaskAPI) -> None:

View File

@ -7,18 +7,17 @@ import asyncio
from collections import (
Counter,
)
from collections.abc import (
Awaitable,
Iterable,
Sequence,
)
import logging
import sys
from typing import (
Any,
Awaitable,
Callable,
Iterable,
List,
Optional,
Sequence,
Set,
Type,
TypeVar,
cast,
)
@ -79,7 +78,7 @@ class Service(ServiceAPI):
LogicFnType = Callable[..., Awaitable[Any]]
def as_service(service_fn: LogicFnType) -> Type[ServiceAPI]:
def as_service(service_fn: LogicFnType) -> type[ServiceAPI]:
"""
Create a service out of a simple function
"""
@ -143,7 +142,7 @@ T = TypeVar("T", bound="BaseFunctionTask")
class BaseFunctionTask(BaseTaskWithChildren):
@classmethod
def iterate_tasks(cls: Type[T], *tasks: TaskAPI) -> Iterable[T]:
def iterate_tasks(cls: type[T], *tasks: TaskAPI) -> Iterable[T]:
for task in tasks:
if isinstance(task, cls):
yield task
@ -206,7 +205,7 @@ class BaseManager(InternalManagerAPI):
_service: ServiceAPI
_errors: List[EXC_INFO]
_errors: list[EXC_INFO]
def __init__(self, service: ServiceAPI) -> None:
if hasattr(service, "_manager"):
@ -220,7 +219,7 @@ class BaseManager(InternalManagerAPI):
self._errors = []
# tasks
self._root_tasks: Set[TaskAPI] = set()
self._root_tasks: set[TaskAPI] = set()
# stats
self._total_task_count = 0

View File

@ -3,6 +3,12 @@ from __future__ import (
annotations,
)
from collections.abc import (
AsyncIterator,
Awaitable,
Coroutine,
Sequence,
)
from contextlib import (
asynccontextmanager,
)
@ -10,13 +16,8 @@ import functools
import sys
from typing import (
Any,
AsyncIterator,
Awaitable,
Callable,
Coroutine,
Optional,
Sequence,
Tuple,
TypeVar,
cast,
)
@ -337,7 +338,7 @@ class TrioManager(BaseManager):
TFunc = TypeVar("TFunc", bound=Callable[..., Coroutine[Any, Any, Any]])
_ChannelPayload = Tuple[Optional[Any], Optional[BaseException]]
_ChannelPayload = tuple[Optional[Any], Optional[BaseException]]
async def _wait_finished(

View File

@ -1,16 +1,16 @@
# Copied from https://github.com/ethereum/async-service
from collections.abc import (
Awaitable,
)
from types import (
TracebackType,
)
from typing import (
Any,
Awaitable,
Callable,
Tuple,
Type,
)
EXC_INFO = Tuple[Type[BaseException], BaseException, TracebackType]
EXC_INFO = tuple[type[BaseException], BaseException, TracebackType]
AsyncFn = Callable[..., Awaitable[Any]]