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

@ -1658,6 +1658,20 @@ Introspection helpers
.. versionadded:: 3.8
.. function:: is_typeddict(tp)
Check if an annotation is a TypedDict class.
For example::
class Film(TypedDict):
title: str
year: int
is_typeddict(Film) # => True
is_typeddict(Union[list, str]) # => False
.. versionadded:: 3.10
.. class:: ForwardRef
A class used for internal typing representation of string forward references.