mirror of
https://github.com/python/cpython.git
synced 2025-11-17 01:25:57 +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
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue