mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-41792: Add is_typeddict function to typing.py (GH-22254)
Closes issue41792. Also closes https://github.com/python/typing/issues/751.
This commit is contained in:
parent
22415ad625
commit
0705ec8a14
4 changed files with 42 additions and 0 deletions
|
@ -16,6 +16,7 @@ from typing import Generic, ClassVar, Final, final, Protocol
|
|||
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 no_type_check, no_type_check_decorator
|
||||
from typing import Type
|
||||
from typing import NewType
|
||||
|
@ -3900,6 +3901,12 @@ class TypedDictTests(BaseTestCase):
|
|||
'voice': str,
|
||||
}
|
||||
|
||||
def test_is_typeddict(self):
|
||||
assert is_typeddict(Point2D) is True
|
||||
assert is_typeddict(Union[str, int]) is False
|
||||
# classes, not instances
|
||||
assert is_typeddict(Point2D()) is False
|
||||
|
||||
|
||||
class IOTests(BaseTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue