diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_typing.py | 11 | ||||
-rw-r--r-- | Lib/typing.py | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index ab9d8a0..7f9c10d 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -8123,6 +8123,17 @@ class RETests(BaseTestCase): self.assertEqual(__name__, 'typing.re') self.assertEqual(len(w), 1) + def test_re_submodule_access_basics(self): + with warnings.catch_warnings(): + warnings.filterwarnings("error", category=DeprecationWarning) + from typing import re + self.assertIsInstance(re.__doc__, str) + self.assertEqual(re.__name__, "typing.re") + self.assertIsInstance(re.__dict__, types.MappingProxyType) + + with self.assertWarns(DeprecationWarning): + re.Match + def test_cannot_subclass(self): with self.assertRaisesRegex( TypeError, diff --git a/Lib/typing.py b/Lib/typing.py index cbd4ce8..1e4c725 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3256,11 +3256,11 @@ class TextIO(IO[str]): class _DeprecatedType(type): def __getattribute__(cls, name): - if name not in ("__dict__", "__module__") and name in cls.__dict__: + if name not in {"__dict__", "__module__", "__doc__"} and name in cls.__dict__: warnings.warn( f"{cls.__name__} is deprecated, import directly " f"from typing instead. {cls.__name__} will be removed " - "in Python 3.12.", + "in Python 3.13.", DeprecationWarning, stacklevel=2, ) |