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()
Comment on lines +3323 to +3329

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the improvement but the 'int' part is IMO a bit confusing. Would you be willing to create a better example of overloaded functions?


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

Expand Down
Loading