diff options
Diffstat (limited to 'Lib/typing.py')
| -rw-r--r-- | Lib/typing.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index 2aedbeb852..8c61bd8e08 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -103,6 +103,7 @@ __all__ = [ 'get_args', 'get_origin', 'get_type_hints', + 'is_typeddict', 'NewType', 'no_type_check', 'no_type_check_decorator', @@ -1479,6 +1480,20 @@ def get_args(tp): return () +def 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 + """ + return isinstance(tp, _TypedDictMeta) + + def no_type_check(arg): """Decorator to indicate that annotations are not type hints. |
