mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-46414: Add typing.reveal_type (#30646)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
b1288964e3
commit
abcc3d75f6
4 changed files with 63 additions and 1 deletions
|
@ -20,6 +20,7 @@ from typing import cast, runtime_checkable
|
|||
from typing import get_type_hints
|
||||
from typing import get_origin, get_args
|
||||
from typing import is_typeddict
|
||||
from typing import reveal_type
|
||||
from typing import no_type_check, no_type_check_decorator
|
||||
from typing import Type
|
||||
from typing import NamedTuple, TypedDict
|
||||
|
@ -34,7 +35,7 @@ import typing
|
|||
import weakref
|
||||
import types
|
||||
|
||||
from test.support import import_helper
|
||||
from test.support import import_helper, captured_stderr
|
||||
from test import mod_generics_cache
|
||||
from test import _typed_dict_helper
|
||||
|
||||
|
@ -5289,6 +5290,14 @@ class SpecialAttrsTests(BaseTestCase):
|
|||
self.assertIn('baz', dir(Foo[int]))
|
||||
|
||||
|
||||
class RevealTypeTests(BaseTestCase):
|
||||
def test_reveal_type(self):
|
||||
obj = object()
|
||||
with captured_stderr() as stderr:
|
||||
self.assertIs(obj, reveal_type(obj))
|
||||
self.assertEqual(stderr.getvalue(), "Runtime type is 'object'\n")
|
||||
|
||||
|
||||
class AllTests(BaseTestCase):
|
||||
"""Tests for __all__."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue