summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-05-13 08:55:35 (GMT)
committerGitHub <noreply@github.com>2023-05-13 08:55:35 (GMT)
commitc527eb1c2a473df01c19195b378f780e9180fd1c (patch)
tree6a633c3d205d07a496b85020b8ac344d8e97cee2 /Lib/typing.py
parent1be80ed107deb15b926f2794b8e6a7a527b8b84c (diff)
downloadcpython-c527eb1c2a473df01c19195b378f780e9180fd1c.zip
cpython-c527eb1c2a473df01c19195b378f780e9180fd1c.tar.gz
cpython-c527eb1c2a473df01c19195b378f780e9180fd1c.tar.bz2
gh-91896: Revert some very noisy DeprecationWarnings for `ByteString` (#104424)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py27
1 files changed, 3 insertions, 24 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 513d4d9..61aed09 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -2772,6 +2772,9 @@ Mapping = _alias(collections.abc.Mapping, 2)
MutableMapping = _alias(collections.abc.MutableMapping, 2)
Sequence = _alias(collections.abc.Sequence, 1)
MutableSequence = _alias(collections.abc.MutableSequence, 1)
+ByteString = _DeprecatedGenericAlias(
+ collections.abc.ByteString, 0, removal_version=(3, 14) # Not generic.
+)
# Tuple accepts variable number of parameters.
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
Tuple.__doc__ = \
@@ -3571,27 +3574,3 @@ def override(method: F, /) -> F:
# read-only property, TypeError if it's a builtin class.
pass
return method
-
-
-def __getattr__(attr):
- if attr == "ByteString":
- import warnings
- warnings._deprecated("typing.ByteString", remove=(3, 14))
- with warnings.catch_warnings(
- action="ignore", category=DeprecationWarning
- ):
- # Not generic
- ByteString = globals()["ByteString"] = _DeprecatedGenericAlias(
- collections.abc.ByteString, 0, removal_version=(3, 14)
- )
- return ByteString
- raise AttributeError(f"module 'typing' has no attribute {attr!r}")
-
-
-def _remove_cached_ByteString_from_globals():
- try:
- del globals()["ByteString"]
- except KeyError:
- pass
-
-_cleanups.append(_remove_cached_ByteString_from_globals)