diff options
author | Michael The <michael-the1@users.noreply.github.com> | 2023-07-31 15:43:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-31 15:43:53 (GMT) |
commit | a22ff8e11c114e0c4c54c57b9e7f7520db9d5163 (patch) | |
tree | bd080edc0bbf49423b0fd319551c16109de5ea33 | |
parent | f877b32b879f2076bb1c52826af0c28ebf1aaeed (diff) | |
download | cpython-a22ff8e11c114e0c4c54c57b9e7f7520db9d5163.zip cpython-a22ff8e11c114e0c4c54c57b9e7f7520db9d5163.tar.gz cpython-a22ff8e11c114e0c4c54c57b9e7f7520db9d5163.tar.bz2 |
gh-105578: Document that `AnyStr` is deprecated in py313 (#107116)
It will not be removed until Python 3.18.
-rw-r--r-- | Doc/library/typing.rst | 14 | ||||
-rw-r--r-- | Doc/whatsnew/3.13.rst | 6 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2023-07-23-13-05-32.gh-issue-105578.XAQtyR.rst | 2 |
3 files changed, 22 insertions, 0 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 539203f..f96a805 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -864,6 +864,16 @@ using ``[]``. def greet_proper(cond: bool) -> str | bytes: return "hi there!" if cond else b"greetings!" + .. deprecated-removed:: 3.13 3.18 + Deprecated in favor of the new :ref:`type parameter syntax <type-params>`. + Use ``class A[T: (str, bytes)]: ...`` instead of importing ``AnyStr``. See + :pep:`695` for more details. + + In Python 3.16, ``AnyStr`` will be removed from ``typing.__all__``, and + deprecation warnings will be emitted at runtime when it is accessed or + imported from ``typing``. ``AnyStr`` will be removed from ``typing`` + in Python 3.18. + .. data:: LiteralString Special type that includes only literal strings. @@ -3700,3 +3710,7 @@ convenience. This is subject to change, and not all deprecations are listed. - 3.13 - 3.15 - :gh:`106309` + * - :data:`typing.AnyStr` + - 3.13 + - 3.18 + - :gh:`105578` diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index e20832a..8fb4e6c 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -196,6 +196,12 @@ Deprecated has yet to be supported by any major type checkers. (Contributed by Alex Waygood in :gh:`106309`.) + * :data:`typing.AnyStr` is deprecated. In Python 3.16, it will be removed from + ``typing.__all__``, and a :exc:`DeprecationWarning` will be emitted when it + is imported or accessed. It will be removed entirely in Python 3.18. Use + the new :ref:`type parameter syntax <type-params>` instead. + (Contributed by Michael The in :gh:`107116`.) + * :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes. They will be removed in Python 3.15. diff --git a/Misc/NEWS.d/next/Library/2023-07-23-13-05-32.gh-issue-105578.XAQtyR.rst b/Misc/NEWS.d/next/Library/2023-07-23-13-05-32.gh-issue-105578.XAQtyR.rst new file mode 100644 index 0000000..4a03f5c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-07-23-13-05-32.gh-issue-105578.XAQtyR.rst @@ -0,0 +1,2 @@ +Deprecate :class:`typing.AnyStr` in favor of the new Type Parameter syntax. +See PEP 695. |