Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading