Skip to content

Commit 8160870

Browse files
authored
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 <bradley.reynolds@tailstory.dev>
1 parent a2c999b commit 8160870

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎Doc/library/typing.rst‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,8 +3320,13 @@ Functions and decorators
33203320
@overload
33213321
def process(response: bytes) -> str:
33223322
...
3323-
def process(response):
3324-
... # actual implementation goes here
3323+
def process(response: int | bytes | None) -> tuple[int, str] | str | None:
3324+
# The implementation is not decorated with @overload
3325+
if response is None:
3326+
return None
3327+
if isinstance(response, int):
3328+
return response, str(response)
3329+
return response.decode()
33253330

33263331
See :pep:`484` for more details and comparison with other typing semantics.
33273332

0 commit comments

Comments
 (0)