diff --git a/sanic/compat.py b/sanic/compat.py index e0271747..3a9c372a 100644 --- a/sanic/compat.py +++ b/sanic/compat.py @@ -133,7 +133,7 @@ if use_trio: # pragma: no cover return trio.Path(path).stat() open_async = trio.open_file - CancelledErrors = (asyncio.CancelledError, trio.Cancelled) + CancelledErrors: tuple[type[BaseException], ...] = (asyncio.CancelledError, trio.Cancelled) else: if PYPY_IMPLEMENTATION: pypy_os_module_patch() diff --git a/sanic/models/protocol_types.py b/sanic/models/protocol_types.py index e2c70c4d..7d40a44e 100644 --- a/sanic/models/protocol_types.py +++ b/sanic/models/protocol_types.py @@ -1,7 +1,7 @@ from __future__ import annotations from asyncio import BaseTransport -from typing import TYPE_CHECKING, AnyStr +from typing import TYPE_CHECKING if TYPE_CHECKING: from sanic.http.constants import HTTP @@ -12,10 +12,10 @@ from typing import Protocol class HTMLProtocol(Protocol): - def __html__(self) -> AnyStr: + def __html__(self) -> str: ... - def _repr_html_(self) -> AnyStr: + def _repr_html_(self) -> str: ... diff --git a/sanic/server/protocols/base_protocol.py b/sanic/server/protocols/base_protocol.py index 8678f471..087694a1 100644 --- a/sanic/server/protocols/base_protocol.py +++ b/sanic/server/protocols/base_protocol.py @@ -51,8 +51,8 @@ class SanicProtocol(asyncio.Protocol): self._can_write = asyncio.Event() self._can_write.set() self._unix = unix - self._time = 0.0 # type: float - self._task = None # type: Optional[asyncio.Task] + self._time = 0.0 + self._task: asyncio.Task | None = None self._data_received = asyncio.Event() @property