From 9cd2b0f56503b539a8f3cc86297fbe1e42b78e4c Mon Sep 17 00:00:00 2001 From: Michael The Date: Sun, 23 Jul 2023 12:29:01 +0200 Subject: [PATCH 1/9] Deprecate AnyStr in the docs --- Doc/library/typing.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 0265a39ce646f4..077631728d95e6 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -831,6 +831,11 @@ using ``[]``. .. data:: AnyStr + .. deprecated:: 3.13 + Deprecated in favor of the new type parameter syntax. Use + ``class A[T: (str, bytes)]: ...`` instead of importing ``AnyStr``. See + :pep:`695` for more details. + A :ref:`constrained type variable `. Definition:: From ebd0e7a8f149662b944557abcfb604442fcd9d86 Mon Sep 17 00:00:00 2001 From: Michael The Date: Sun, 23 Jul 2023 13:06:13 +0200 Subject: [PATCH 2/9] Add NEWS entry --- .../next/Library/2023-07-23-13-05-32.gh-issue-105578.XAQtyR.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2023-07-23-13-05-32.gh-issue-105578.XAQtyR.rst 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 00000000000000..4a03f5c35ff6c0 --- /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. From d0b90d263547511b8cf6dcc95882f4f5997960fe Mon Sep 17 00:00:00 2001 From: Michael The Date: Sun, 23 Jul 2023 13:44:18 +0200 Subject: [PATCH 3/9] Add deprecation of AnyStr to What's New --- Doc/whatsnew/3.13.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 1d34d8a0fa463c..fc37034ff7dea3 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -188,6 +188,11 @@ Deprecated has yet to be supported by any major type checkers. (Contributed by Alex Waygood in :gh:`106309`.) + * :class:`typing.AnyStr` is deprecated in docs since Python 3.13. The intention + is to remove `AnyStr` from `__all__` and emit a :exc:`DeprecationWarning` + in Python 3.16, and to remove `AnyStr` entirely in Python 3.18. + (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. @@ -332,6 +337,11 @@ Pending Removal in Python 3.16 * :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use the ``'w'`` type instead (``Py_UCS4``). +Pending Removal in Python 3.18 +------------------------------ + +* :class:`typing.AnyStr` (:gh:`105578`) + Pending Removal in Future Versions ---------------------------------- From 4e074655488de7df529290337dafa1b7705566ad Mon Sep 17 00:00:00 2001 From: Michael The Date: Sun, 23 Jul 2023 13:49:20 +0200 Subject: [PATCH 4/9] Add missing backticks and class markers --- Doc/whatsnew/3.13.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index fc37034ff7dea3..def4b913cd34e1 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -189,8 +189,8 @@ Deprecated (Contributed by Alex Waygood in :gh:`106309`.) * :class:`typing.AnyStr` is deprecated in docs since Python 3.13. The intention - is to remove `AnyStr` from `__all__` and emit a :exc:`DeprecationWarning` - in Python 3.16, and to remove `AnyStr` entirely in Python 3.18. + is to remove :class:`AnyStr` from ``__all__`` and emit a :exc:`DeprecationWarning` + in Python 3.16, and to remove :class:`AnyStr` entirely in Python 3.18. (Contributed by Michael The in :gh:`107116`.) * :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` From e51779927bad0dd48b4748bbf762fbb3bee99c1e Mon Sep 17 00:00:00 2001 From: Michael The Date: Sun, 23 Jul 2023 13:54:23 +0200 Subject: [PATCH 5/9] Fix formatting in What's New --- Doc/whatsnew/3.13.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index def4b913cd34e1..586df914483726 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -189,8 +189,8 @@ Deprecated (Contributed by Alex Waygood in :gh:`106309`.) * :class:`typing.AnyStr` is deprecated in docs since Python 3.13. The intention - is to remove :class:`AnyStr` from ``__all__`` and emit a :exc:`DeprecationWarning` - in Python 3.16, and to remove :class:`AnyStr` entirely in Python 3.18. + is to remove ``AnyStr`` from ``__all__`` and emit a :exc:`DeprecationWarning` + in Python 3.16, and to remove ``AnyStr`` entirely in Python 3.18. (Contributed by Michael The in :gh:`107116`.) * :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` @@ -340,7 +340,7 @@ Pending Removal in Python 3.16 Pending Removal in Python 3.18 ------------------------------ -* :class:`typing.AnyStr` (:gh:`105578`) +* :class:`typing.AnyStr`: Use the new type parameter syntax instead. See :pep:`695`. (:gh:`105578`) Pending Removal in Future Versions ---------------------------------- From 0d2d4b00c40e34dc5f0687d009effe0052d20ac9 Mon Sep 17 00:00:00 2001 From: Michael The Date: Tue, 25 Jul 2023 23:19:01 +0200 Subject: [PATCH 6/9] Improve deprecation comments Co-authored-by: Alex Waygood --- Doc/library/typing.rst | 7 ++++++- Doc/whatsnew/3.13.rst | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 077631728d95e6..b97efc1218d969 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -831,11 +831,16 @@ using ``[]``. .. data:: AnyStr - .. deprecated:: 3.13 + .. deprecated-removed:: 3.13 3.18 Deprecated in favor of the new type parameter syntax. 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. + A :ref:`constrained type variable `. Definition:: diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 586df914483726..b83ec69223ca23 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -188,9 +188,9 @@ Deprecated has yet to be supported by any major type checkers. (Contributed by Alex Waygood in :gh:`106309`.) - * :class:`typing.AnyStr` is deprecated in docs since Python 3.13. The intention - is to remove ``AnyStr`` from ``__all__`` and emit a :exc:`DeprecationWarning` - in Python 3.16, and to remove ``AnyStr`` entirely in Python 3.18. + * :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. (Contributed by Michael The in :gh:`107116`.) * :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` From 2c948cba979204acbf1259b6813d50fd4911fb68 Mon Sep 17 00:00:00 2001 From: Michael The Date: Tue, 25 Jul 2023 23:26:29 +0200 Subject: [PATCH 7/9] Add deprecation of AnyStr to the Big Table at the bottom --- Doc/library/typing.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index b97efc1218d969..43ff76fb42e338 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -3698,3 +3698,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` From c9df1220c100913b1d5ba8bc33c162b0431b2992 Mon Sep 17 00:00:00 2001 From: Michael The Date: Sun, 30 Jul 2023 18:10:56 +0200 Subject: [PATCH 8/9] Add reference to type-params section --- Doc/library/typing.rst | 4 ++-- Doc/whatsnew/3.13.rst | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 43ff76fb42e338..74fcce7926aeac 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -832,8 +832,8 @@ using ``[]``. .. data:: AnyStr .. deprecated-removed:: 3.13 3.18 - Deprecated in favor of the new type parameter syntax. Use - ``class A[T: (str, bytes)]: ...`` instead of importing ``AnyStr``. See + Deprecated in favor of the new :ref:`type parameter syntax `. + 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 diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index b83ec69223ca23..42de074f00cd3c 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -190,7 +190,8 @@ Deprecated * :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. + is imported or accessed. It will be removed entirely in Python 3.18. Use + the new :ref:`type parameter syntax ` instead. (Contributed by Michael The in :gh:`107116`.) * :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` @@ -340,7 +341,7 @@ Pending Removal in Python 3.16 Pending Removal in Python 3.18 ------------------------------ -* :class:`typing.AnyStr`: Use the new type parameter syntax instead. See :pep:`695`. (:gh:`105578`) +* :class:`typing.AnyStr`: Use the new :ref:`type parameter syntax ` instead. See :pep:`695`. (:gh:`105578`) Pending Removal in Future Versions ---------------------------------- From 8e32e2968f601b3a4e8a08c9872d2412174013d3 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 31 Jul 2023 16:33:06 +0100 Subject: [PATCH 9/9] Small fixups --- Doc/library/typing.rst | 20 ++++++++++---------- Doc/whatsnew/3.13.rst | 5 ----- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 7f0a5bca7a7eea..f96a805cef7b2d 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -831,16 +831,6 @@ using ``[]``. .. data:: AnyStr - .. deprecated-removed:: 3.13 3.18 - Deprecated in favor of the new :ref:`type parameter syntax `. - 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. - A :ref:`constrained type variable `. Definition:: @@ -874,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 `. + 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. diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 609155eb2214f4..8fb4e6cfdf14c7 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -346,11 +346,6 @@ Pending Removal in Python 3.16 * :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use the ``'w'`` type instead (``Py_UCS4``). -Pending Removal in Python 3.18 ------------------------------- - -* :class:`typing.AnyStr`: Use the new :ref:`type parameter syntax ` instead. See :pep:`695`. (:gh:`105578`) - Pending Removal in Future Versions ----------------------------------