From a1f179d1c98cea275278a540bd82f6308f5ef2f4 Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Tue, 5 Dec 2023 12:34:00 -0800 Subject: [PATCH] use builtin TimeoutError in asyncio and concurrent.futures related to https://github.com/python/typeshed/issues/3968 --- stdlib/asyncio/exceptions.pyi | 7 ++++++- stdlib/concurrent/futures/_base.pyi | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/stdlib/asyncio/exceptions.pyi b/stdlib/asyncio/exceptions.pyi index 075fbb805bb9..0746394d582f 100644 --- a/stdlib/asyncio/exceptions.pyi +++ b/stdlib/asyncio/exceptions.pyi @@ -21,7 +21,12 @@ else: ) class CancelledError(BaseException): ... -class TimeoutError(Exception): ... + +if sys.version_info >= (3, 11): + from builtins import TimeoutError as TimeoutError +else: + class TimeoutError(Exception): ... + class InvalidStateError(Exception): ... class SendfileNotAvailableError(RuntimeError): ... diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index eb5ca4e2dd35..8a11f47e5670 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -24,7 +24,11 @@ LOGGER: Logger class Error(Exception): ... class CancelledError(Error): ... -class TimeoutError(Error): ... + +if sys.version_info >= (3, 11): + from builtins import TimeoutError as TimeoutError +else: + class TimeoutError(Error): ... if sys.version_info >= (3, 8): class InvalidStateError(Error): ...