Debian Codegraph @

Doc/deprecations/pending-removal-in-3.17.rst

raw
1 Pending removal in Python 3.17
2 ------------------------------
3
4 * :mod:`collections.abc`:
5
6 - :class:`collections.abc.ByteString` is scheduled for removal in Python 3.17.
7
8 Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj``
9 implements the :ref:`buffer protocol <bufferobjects>` at runtime. For use
10 in type annotations, either use :class:`~collections.abc.Buffer` or a union
11 that explicitly specifies the types your code supports (e.g.,
12 ``bytes | bytearray | memoryview``).
13
14 :class:`!ByteString` was originally intended to be an abstract class that
15 would serve as a supertype of both :class:`bytes` and :class:`bytearray`.
16 However, since the ABC never had any methods, knowing that an object was an
17 instance of :class:`!ByteString` never actually told you anything useful
18 about the object. Other common buffer types such as :class:`memoryview`
19 were also never understood as subtypes of :class:`!ByteString` (either at
20 runtime or by static type checkers).
21
22 See :pep:`PEP 688 <688#current-options>` for more details.
23 (Contributed by Shantanu Jain in :gh:`91896`.)
24
25
26 * :mod:`typing`:
27
28 - Before Python 3.14, old-style unions were implemented using the private class
29 ``typing._UnionGenericAlias``. This class is no longer needed for the implementation,
30 but it has been retained for backward compatibility, with removal scheduled for Python
31 3.17. Users should use documented introspection helpers like :func:`typing.get_origin`
32 and :func:`typing.get_args` instead of relying on private implementation details.
33 - :class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for removal in
34 Python 3.17.
35
36 Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj``
37 implements the :ref:`buffer protocol <bufferobjects>` at runtime. For use
38 in type annotations, either use :class:`~collections.abc.Buffer` or a union
39 that explicitly specifies the types your code supports (e.g.,
40 ``bytes | bytearray | memoryview``).
41
42 :class:`!ByteString` was originally intended to be an abstract class that
43 would serve as a supertype of both :class:`bytes` and :class:`bytearray`.
44 However, since the ABC never had any methods, knowing that an object was an
45 instance of :class:`!ByteString` never actually told you anything useful
46 about the object. Other common buffer types such as :class:`memoryview`
47 were also never understood as subtypes of :class:`!ByteString` (either at
48 runtime or by static type checkers).
49
50 See :pep:`PEP 688 <688#current-options>` for more details.
51 (Contributed by Shantanu Jain in :gh:`91896`.)