From 816087024480e1ae912743e96a8efff69e2d2ac4 Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sat, 17 Oct 2026 01:41:27 +0000 Subject: [PATCH] Show a real implementation for typing.overload The typing.overload example ended with a placeholder implementation, so it looked like the overload stubs even though the text says the final undecorated definition is the one that runs. Replace it with a short working implementation. Signed-off-by: Bradley Reynolds --- Doc/library/typing.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index c909b8bad6d726..477f451df08007 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -3320,8 +3320,13 @@ Functions and decorators @overload def process(response: bytes) -> str: ... - def process(response): - ... # actual implementation goes here + def process(response: int | bytes | None) -> tuple[int, str] | str | None: + # The implementation is not decorated with @overload + if response is None: + return None + if isinstance(response, int): + return response, str(response) + return response.decode() See :pep:`484` for more details and comparison with other typing semantics.