-
Notifications
You must be signed in to change notification settings - Fork 266
Replace typing_extensions -> typing in examples #1987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1b1da7a
d14195d
16e7648
b9c365e
9a6ea49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ As an example, consider this simple calculator: | |
.. code:: python | ||
|
||
import enum | ||
from typing_extensions import Never | ||
from typing import Never | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never needs an infobox as well. (Added in Python 3.11.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I didn't add it for that one because it's already explained in the prose at the start of the page; but I've added an additional infobox below the code snippet now for consistency (and perhaps easier discoverability for people who only skim the page) 👍 |
||
|
||
def assert_never(arg: Never) -> Never: | ||
raise AssertionError("Expected code to be unreachable") | ||
|
@@ -72,6 +72,11 @@ As an example, consider this simple calculator: | |
case _: | ||
assert_never(op) | ||
|
||
.. note:: | ||
|
||
To use this feature on Python versions earlier than 3.11, you will need to | ||
import ``Never`` from ``typing_extensions`` (version 4.1 or newer). | ||
|
||
The ``match`` statement covers all members of the ``Op`` enum, | ||
so the ``assert_never()`` call is unreachable and the type checker | ||
will accept this code. However, if you add another member to the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss on the issue for now