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:
Patrick Reader 2020-09-16 05:58:32 +01:00 committed by GitHub
parent 22415ad625
commit 0705ec8a14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 0 deletions

View file

@ -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):