diff --git a/src/trio/_util.py b/src/trio/_util.py index 8c10362f9..f55f0aeca 100644 --- a/src/trio/_util.py +++ b/src/trio/_util.py @@ -27,11 +27,12 @@ import sys from types import AsyncGeneratorType, TracebackType - from typing_extensions import TypeVarTuple, Unpack + from typing_extensions import ParamSpec, TypeVarTuple, Unpack if sys.version_info < (3, 11): from exceptiongroup import BaseExceptionGroup + P = ParamSpec("P") PosArgsT = TypeVarTuple("PosArgsT") @@ -287,8 +288,9 @@ def __call__(cls, *args: object, **kwargs: object) -> None: f"{cls.__module__}.{cls.__qualname__} has no public constructor", ) - def _create(cls: type[T], *args: object, **kwargs: object) -> T: - return super().__call__(*args, **kwargs) # type: ignore + def _create(cls: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> T: + # misc = unsupported argument 2 for "super" (??) + return super().__call__(*args, **kwargs) # type: ignore[misc,no-any-return] def name_asyncgen(agen: AsyncGeneratorType[object, NoReturn]) -> str: diff --git a/src/trio/testing/_fake_net.py b/src/trio/testing/_fake_net.py index 4fed1b0bd..71b5d72fd 100644 --- a/src/trio/testing/_fake_net.py +++ b/src/trio/testing/_fake_net.py @@ -123,7 +123,7 @@ def reply(self, payload: bytes) -> UDPPacket: # pragma: no cover class FakeSocketFactory(trio.abc.SocketFactory): fake_net: FakeNet - def socket(self, family: int, type_: int, proto: int) -> FakeSocket: # type: ignore[override] + def socket(self, family: AddressFamily, type_: SocketKind, proto: int) -> FakeSocket: # type: ignore[override] return FakeSocket._create(self.fake_net, family, type_, proto)