Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review
  • Loading branch information
sobolevn committed May 12, 2023
commit 023a6150942772c433b6c8e5f68b32652e4a9d5e
5 changes: 2 additions & 3 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6004,17 +6004,16 @@ def test_mutablesequence(self):
self.assertNotIsInstance((), typing.MutableSequence)

def test_bytestring(self):
_typing = import_fresh_module('typing')
with self.assertWarns(DeprecationWarning):
ByteString = _typing.ByteString
from typing import ByteString
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(b'', ByteString)
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(bytearray(b''), ByteString)
with self.assertWarns(DeprecationWarning):
class Foo(ByteString): ...
with self.assertWarns(DeprecationWarning):
class Bar(ByteString, _typing.Awaitable): ...
class Bar(ByteString, typing.Awaitable): ...

def test_list(self):
self.assertIsSubclass(list, typing.List)
Expand Down
9 changes: 9 additions & 0 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3586,3 +3586,12 @@ def __getattr__(attr):
)
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)