gh-92871: Remove typing.{io,re} namespaces (#92873)

Closes #92871

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Sebastian Rittau 2023-05-23 15:44:26 +02:00 committed by GitHub
parent 9dc476be2d
commit abdda5b133
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 76 deletions

View file

@ -7529,17 +7529,6 @@ class IOTests(BaseTestCase):
a = stuff.__annotations__['a']
self.assertEqual(a.__parameters__, ())
def test_io_submodule(self):
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings("default", category=DeprecationWarning)
from typing.io import IO, TextIO, BinaryIO, __all__, __name__
self.assertIs(IO, typing.IO)
self.assertIs(TextIO, typing.TextIO)
self.assertIs(BinaryIO, typing.BinaryIO)
self.assertEqual(set(__all__), set(['IO', 'TextIO', 'BinaryIO']))
self.assertEqual(__name__, 'typing.io')
self.assertEqual(len(w), 1)
class RETests(BaseTestCase):
# Much of this is really testing _TypeAlias.
@ -7584,16 +7573,6 @@ class RETests(BaseTestCase):
self.assertEqual(repr(Match[str]), 'typing.Match[str]')
self.assertEqual(repr(Match[bytes]), 'typing.Match[bytes]')
def test_re_submodule(self):
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings("default", category=DeprecationWarning)
from typing.re import Match, Pattern, __all__, __name__
self.assertIs(Match, typing.Match)
self.assertIs(Pattern, typing.Pattern)
self.assertEqual(set(__all__), set(['Match', 'Pattern']))
self.assertEqual(__name__, 'typing.re')
self.assertEqual(len(w), 1)
def test_cannot_subclass(self):
with self.assertRaisesRegex(
TypeError,
@ -8765,7 +8744,7 @@ class AllTests(BaseTestCase):
# Context managers.
self.assertIn('ContextManager', a)
self.assertIn('AsyncContextManager', a)
# Check that io and re are not exported.
# Check that former namespaces io and re are not exported.
self.assertNotIn('io', a)
self.assertNotIn('re', a)
# Spot-check that stdlib modules aren't exported.
@ -8785,7 +8764,6 @@ class AllTests(BaseTestCase):
if k in actual_all or (
# avoid private names
not k.startswith('_') and
k not in {'io', 're'} and
# there's a few types and metaclasses that aren't exported
not k.endswith(('Meta', '_contra', '_co')) and
not k.upper() == k and