Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed May 12, 2023
1 parent e8f6c3d commit 023a615
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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)

0 comments on commit 023a615

Please sign in to comment.