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.
- 3.13
- 3.15
- :gh:`106309`
+ * - :data:`typing.AnyStr`
+ - 3.13
+ - 3.18
+ - :gh:`105578`
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.