Skip to content

Commit

Permalink
Update docs not to mention 3.8 where possible (#18455)
Browse files Browse the repository at this point in the history
I updated docs to not mention EOL 3.8, where it is possible to use other
versions / examples.
  • Loading branch information
sobolevn authored Jan 13, 2025
1 parent a49d991 commit ee1f4c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/source/common_issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ More specifically, mypy will understand the use of :py:data:`sys.version_info` a
import sys
# Distinguishing between different versions of Python:
if sys.version_info >= (3, 8):
# Python 3.8+ specific definitions and imports
if sys.version_info >= (3, 13):
# Python 3.13+ specific definitions and imports
else:
# Other definitions and imports
Expand Down
16 changes: 6 additions & 10 deletions docs/source/runtime_troubles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,29 +335,25 @@ Using new additions to the typing module
----------------------------------------

You may find yourself wanting to use features added to the :py:mod:`typing`
module in earlier versions of Python than the addition, for example, using any
of ``Literal``, ``Protocol``, ``TypedDict`` with Python 3.6.
module in earlier versions of Python than the addition.

The easiest way to do this is to install and use the ``typing_extensions``
package from PyPI for the relevant imports, for example:

.. code-block:: python
from typing_extensions import Literal
x: Literal["open", "close"]
from typing_extensions import TypeIs
If you don't want to rely on ``typing_extensions`` being installed on newer
Pythons, you could alternatively use:

.. code-block:: python
import sys
if sys.version_info >= (3, 8):
from typing import Literal
if sys.version_info >= (3, 13):
from typing import TypeIs
else:
from typing_extensions import Literal
x: Literal["open", "close"]
from typing_extensions import TypeIs
This plays nicely well with following :pep:`508` dependency specification:
``typing_extensions; python_version<"3.8"``
``typing_extensions; python_version<"3.13"``

0 comments on commit ee1f4c9

Please sign in to comment.